I would like to have a very lightweight ASP.NET MVC site which includes removing as many of the usual HttpModules as possible and disabling session state. However when I try to do this, I get the following error:
The SessionStateTempDataProvider requires SessionState to be enabled.
I've disabled session state in web.config:
<sessionState mode="Off" />
I understand that ASP.NET MVC uses session state for TempData, but I don't need/want TempData - I just want to disable session state. Help!
You could make your own ControllerFactory and DummyTempDataProvider. Something like this:
And then you would just need to register the controller factory on app startup - e.g. you could do this in global.asax:
If you need to use TempData for simple strings, you can use the CookieTempDataProvider in MvcFutures http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471.
I've found one way, which I don't particularly care for:
Create NoTempDataProvider
Manually Overwrite the Provider in the Controller
I would greatly prefer a way to do this completely via the configuration, but this works for now.
According to Brad Wilson, this has been fixed in MVC 2 Preview 1. See here and here.