This was a doozie... I was working on a local dev box running Windows Vista and .NET 2.0. I pulled down another developer's web project that uses Session State variables, and when I went to test it, I received this error:
"System.Web.HttpException: Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive..."I did some sleuthing, and find different recommendations:
to your web.config file, within the area.
to the same area.
- Make sure
is in the httpModules area of your root level web.config file (some people said machine.config, not sure which, but I tried both).
- Add EnableSessionState="true" to the .aspx @Page directive.
I just figured it out, although I have no idea how or why it was required:
- In IIS Manager (in IIS7), go to the top level of the website in question.
- Instead of clicking on the Session State panel, double-click the "Modules" area.
- Scan that list and see if you have a module for Session State configured (I did not).
- If not, click the Add Managed Module... button.
- Type "Session" in the first box (no quotes).
- In the second box, type "System.Web.SessionState.SessionStateModule" (no quotes)
- Click the checkbox "invoke only requests to asp.net" (at least, that's what I did)