无法使用 asp.net 4 webforms 路由获取 System.Web.SessionState

发布于 2024-09-19 00:25:33 字数 1047 浏览 0 评论 0原文

我在这里看到了几个问题,例如 使用时的状态服务WebForms 中的 system.web.routing 但找不到合适的解决方案。

我在 iis7 上使用带有 webforms 的 asp.net 路由。我在 webconfig 文件中添加了下面的内容,以使其在第一个宫殿中工作

       <system.webServer><modules>
        <remove name="UrlRoutingModule-4.0" />
        <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />   
 </modules>
     </system.webServer>

问题是,当我使用路由页面时,会话状态不可用,并且我发现

Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration.

我已启用会话状态,并且如果我使用 aspx 扩展名而不是路由 url 调用页面本身,则所有内容工作正常。

有人知道如何让会话状态与路由一起工作吗?

I've seen couple of questions here such as State Service when using system.web.routing in WebForms but couldn't find proper solution.

I am using asp.net routing with webforms on iis7. I've added below to webconfig file to get it working at first palace

       <system.webServer><modules>
        <remove name="UrlRoutingModule-4.0" />
        <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />   
 </modules>
     </system.webServer>

Problem is that when i use routed pages Session state is not avaliable and i get

Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <configuration>\<system.web>\<httpModules> section in the application configuration.

I have sesison state enabled and if i call page itself with aspx extension instead of routed url everything works fine.

Anyone know how to get session state work with routing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

oО清风挽发oО 2024-09-26 00:25:33

知道了!请参阅 http://www.heartysoft .com/post/2010/07/26/aspnet-routing-iis7-remember-modules.aspx

<system.webServer> 
<modules > 
<remove name="UrlRoutingModule-4.0" /> 
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" /> 
<remove name="Session"/> 
<add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition=""/> 

got it! see http://www.heartysoft.com/post/2010/07/26/aspnet-routing-iis7-remember-modules.aspx

<system.webServer> 
<modules > 
<remove name="UrlRoutingModule-4.0" /> 
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" /> 
<remove name="Session"/> 
<add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition=""/> 

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文