近期给公司网站添加了伪静态功能,但是今天发现了在伪静态的页面中,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/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。

相关文章:

  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2021-09-07
  • 2021-06-01
  • 2021-07-10
猜你喜欢
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2021-09-18
相关资源
相似解决方案