views:

532

answers:

3

While trying to deploy a simple asp.net mvc project on an IIS 6 server, I keep getting this error "The provider requires SessionState to be enabled".

To rule out that I am doing something wrong, I am now trying to deploy just the template you get when you start a new asp.net mvc solution in vs2008. And yes, I have enabled session state in IIS config, also added the <sessionState mode="InProc" /> line to web.config, but that didn't make any difference.

Tried both the .mvc isapi mapping, as well as the wildcard mapping, and I still get the dreaded error message.

Am I overlooking something obvious ?

+3  A: 

Check your web.config and check make sure that you don't have anything disabling session state. It would look like this.

<sessionState mode="Off" />

Otherwise you may want to check and make sure you have session state enabled at the IIS level by...

  1. Click/select your site
  2. In the Application Settings area select Configuration and then Options tab.
  3. In the Application Configuration area select Enable Session State checkbox (or make sure it's checked).
Chad Moran
Checked and double checked, session state should be working :(.
Morph
Damn I have the same problem ... I've triple checked all the places mentioned above. Anywhere else I could possibly be set? Creating a new site work however ...
Riri
In my case this was due to an web.config file with pages enableSessionState="false" in the default folder for the site ... That apparently got inherited down to the virtual folder.
Riri
+1  A: 

Not really an answer, but what I did was to add a new site to IIS, and let that run on port 81. It's for internal test / demo purpose, so that's not much of a problem.

Then I set up a virtual directory as you can read from many guides out there, setup wildcard isapi rule to the .net 3.5 dll and the site was up right away.

I now ran into the The provider requires SessionState to be enabled - error twice. On my testmachine at home and here at work, while deploying an mvc site to the default website in IIS 6, something must be going wrong, but can't tell you what...

And thanks Chad for trying to help me !

Morph
A: 

I had the same error, but in my case it had nothing to do with sessionstate (at least, it's not the source of the problem).

Have you set up error handling in your Global.asax file? If so, disable it for now.

protected void Application_Error(object sender, EventArgs e)
{
    Exception exception = Server.GetLastError();
    RouteData routeData = new RouteData();
    routeData.Values.Add("controller", "ErrorController");
    routeData.Values.Add("action", "HandleTheError");
    routeData.Values.Add("error", exception);

    Response.Clear();
    Server.ClearError();

    IController errorController = new ErrorController();
    errorController.Execute(new RequestContext(
        new HttpContextWrapper(Context), routeData));
}

After disabling this code I got an http 404 error that one of my pages could not be found. Don't forget to add the mvc extension to your links. If resolving the rootdirectory is your problem, use the function Url.Content in combination with "~/".

Michel van Engelen