My hybrid (web forms/MVC) project is working fine in my local development environment BUT when I deploy (xcopy) to my Test environment I get the error that SessionState is n
Please make sure your ASP.NET State Service (aspnet_state.exe) is running if you configured SessionState to use StateServer:
<sessionState mode="StateServer" ... />
That was my reason of that error.
Add the following to <system.webServer> <modules>
:
<add name="SessionStateModule" type="System.Web.SessionState.SessionStateModule" />
Google Solved: I added this attribute to the modules node in the web.config and EVERYTHING magically started working:
<modules runAllManagedModulesForAllRequests="true">
It looks like I'm not alone:
http://forums.asp.net/p/1293974/2509190.aspx
http://www.flyvergrillen.dk/2009/03/26/being-trapped-in-iis/
I think my pure MVC project (that worked in Test environment) was too simple and may not have forced the MVC framework to require TempData and SessionState, so that's how I'll explain it away ;-)
Add the following entry to system.webServer/handlers
<add name="MvcHttpHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc"/>
Change path="*.mvc"
to whatever extension/path you are using.
Using runAllManagedModulesForAllRequests="true"
is not a very good solution because all modules will run for every request, including static files, which can be bad for performance.
I had the same problem and was of course getting the same error. Even though, I did not need the Session state for my MVC application, I was just interested in getting the application up and running so was willing to enable the session state...why not!!
Even after adding the session state setting to my web.config file,
<system.web>...<sessionState mode="InProc" />...</system.web>
I continued to get the same error message....very confusing!.
I discovered the following explanation which was the definitive resolution to the issue. When running the app pool in integrated mode, you have to ensure that IIS has the session state module mapping defined.
If you happen to be using SQLServer as the sessionState mode such as
<sessionState mode="SQLServer" sqlConnectionString="data source=server;integrated security=true" cookieless="false" />
make sure the connection string is correct and you have permission to the database. I realize this question was for InProc mode, but I hit the same error when I forgot to grant privs to the account my app was running as and this question was the top hit in my Google search.