Wednesday, April 6, 2011

Weird Error : Session state can only be used when enableSessionState is set to true

Today i have faced an very strange error "Session state can only be used when enableSessionState is set to true, either in a configuration file or in the directive. Please also make sure that System.Web....."

This error occurred only on the Windows Server 2008 R2 machine with IIS7. My other ITG servers and DEV Servers with Windows Server 2003 (IIS6) does not throw this error.

I have added the entries in the web.config () and also in the specific pages to enable the session state. But the same error.

Checked the IIS 7 modules for the session element and it was present.

Fianlly after a lot of struggle i have found the solution. We need to add the following entry in the web.config file.



It fixed the problem and the application came up.

I would recommend to check the following entries in your web.config file always when you work with IIS7 and any version of ASP.Net.

1. <..system.web..> <..sessionState mode = "InProc"/..> ... <../system.web..>
2. <..httpModules..><..add name="session" type="System.Web.SessionState.SessionStateModule"/..>
3. <..pages enableSessionState="true" ../>

Hope it helps.

No comments:

Post a Comment