Enable/Disable Session State

Hi all,

Here is a something that came up during a discussion I was having today and I have yet to find a solution either via searching with google or chatting with other developers.

I know you can enable session support via the page directive but does anyone know of a method of setting session state to true, false or read only via code in a code behind file? I wish to set it in my c# page to enable it, disable it or make it read only at the page level.

If it isn't possible (Which I hope there is some documented/undocumented way), will it be possible in asp.net 2?

If you know of a method please add it (or a link to a solution) via my comments so that everyone else can also see how it's done.

Many Thanks,

John 

1 Comment

  • i believe asp.net websites need to know at startup time whether or not session is enabled (needs to load the correct httpmodules into memory). changing this setting (either through code or otherwise) would force an application restart...and if you did this via code, the performance penalties could be drastic, not to mention any objects currently stored in session would be dumped. of course, i would love to be proved wrong here (just going on assumptions). hth.

Comments have been disabled for this content.