Archive for March, 2009

Being trapped in IIS

Thursday, March 26th, 2009

Mikkel has just spend a lot of time trying to get ASP.net MVC to work on a server. During this quest he bumped in to a lot of headache inducing problems the worst of which I will describe here and provide some sort of solution.

The error our dear setup threw at us was:

System.InvalidOperationException:
    The SessionStateTempDataProvider requires SessionState to be enabled.

The only results on google were suggesting to add a line in web.config to tell ISS and ASP.net that sessionState mode should be enabled. Trying this and still getting the same error we found this:

On the Session State tab in IIS, is it also set to enabled?

If you are reading this, you are probably having the some understanding of how the IIS7 management gui works and how it looks. It has no notion of Tabs, and no configuration icons relating to session at all.

Poking around at every concievable way to add SessionState we found that it was possible to add a module named:

System.Web.SessionState.SessionStateModule

Adding that module created the following in web.config:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
       <add name="SessionStateModule"
            type="System.Web.SessionState.SessionStateModule" />

Rembering to add this:

<system.web>
   <sessionState mode="InProc" />
</system.web>

made the server happy.

Hopefully someone in the same situation will find this helpful.

ps: If you are getting weird errors (0×80070021) about system.webServer handlers not being recognized you’ll need to enable them using the cheatcodes:

%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers
%windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/modules