zoukankan      html  css  js  c++  java
  • IIS集成模式下,URL重写后获取不到Session值

    近期给公司网站添加了伪静态功能,但是今天发现了在伪静态的页面中,Session值是获取不到的。

    原因是在伪静态请求的时候,Session请求被“过滤”掉了。

    开始是把web.config文件中的modules节点添加runAllManagedModulesForAllRequests="true"属性。

    <modules runAllManagedModulesForAllRequests="true">
       <add name="URLModule" type="TravelOnline.Web.Module.URLModule"/>
       <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
    </modules>

    这种方法是把所有的请求都传输给处理伪静态的类中,虽然Session是取到了,然而并不可取。

    最后是在modules节点中,添加Session状态模块。

    <modules>
       <add name="URLModule" type="TravelOnline.Web.Module.URLModule"/>
       <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
       <remove name="Session"/>
       <add name="Session" type="System.Web.SessionState.SessionStateModule"/>
    </modules>

    作者:黄昌
    出处:http://www.cnblogs.com/h-change/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。

  • 相关阅读:
    Pthon3各平台的安装
    scrapy爬虫 简单入门
    自动定时打卡7.13
    centos7+python3+selenium+chrome
    在Ubuntu安装kubernetes
    在Ubuntu下安装Jenkins
    在Ubuntu安装Docker
    猫眼100 爬虫
    python 招聘数据分析
    mysql8.0.19忘记密码
  • 原文地址:https://www.cnblogs.com/h-change/p/5063905.html
Copyright © 2011-2022 走看看