views:

53

answers:

1

I've seen couple of questions here such as http://stackoverflow.com/questions/161221/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?

+1  A: 

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=""/> 

nLL
If you are using .NET4.0 and VS2010, you shouldn't need to specify UrlRouting and SessionState modules in web.config at all, it's all done automatically for you.
Shagglez
I am but it didn't
nLL