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/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。

posted @ 2015-12-21 16:49  某C  阅读(453)  评论(0编辑  收藏  举报