2010-09-14 62 views
2

我見過幾個問題,如State Service when using system.web.routing in WebForms但找不到合適的解決方案。無法獲取System.Web.SessionState與asp.net 4 webforms路由

我使用asp.net路由與iis7 webforms。我下面添加到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. 

我已經sesison狀態如果我用aspx擴展而不是路由url調用頁面本身,一切正常。

任何人都知道如何獲得會話狀態與路由工作?

回答

2

明白了!見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=""/> 

+0

如果您使用的.NET4.0和VS2010,你不應該需要在所有指定的web.config UrlRouting和SessionState的模塊,這一切都爲你自動完成。 – Shagglez 2010-10-27 14:36:41

+0

我是,但它沒有 – nLL 2010-10-27 19:28:03