Asp.net-mvc – The SessionStateTempDataProvider requires SessionState to be enabled

asp.net-mvc

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 needed (full error shown below).

What's strange about this error message is that session state is set as InProc in my web.config and IIS7 configuration shows it as as well.

I'm running a classic web forms site and only have one small section that I'm moving over to MVC 1.0. And now my regular web forms default.aspx page isn't able to come up!

  • I don't use the TempData provider at all in MVC so I'm guessing the framework does for some reason but heck, my SesionState is Enabled…
  • My test environment is running on IIS 7 in Integrated mode with my webconfig with sessionstate as InProc and works fine.

More Info: For fun I created a stub project that was MVC only and deployed it to the Test environment and it worked fine! The web.config's are essentially the same and one works and the other doesn't.

Any help is appreciated.


Error Message

Server Error in '/' Application.

The SessionStateTempDataProvider requires SessionState to be enabled.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The SessionStateTempDataProvider requires SessionState to be enabled.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: The SessionStateTempDataProvider requires SessionState to be enabled.]
System.Web.Mvc.SessionStateTempDataProvider.LoadTempData(ControllerContext controllerContext) +247928
System.Web.Mvc.TempDataDictionary.Load(ControllerContext controllerContext, ITempDataProvider tempDataProvider) +30
System.Web.Mvc.Controller.ExecuteCore() +71
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +209
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171

Best Answer

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 ;-)