You mean doing the same than with the EnableSessionSt ate page directive ?
IMO you can't from the page code-behind as your page is already running and
so ASP.NET needed already to know wether session should be activated or not
for this page... This might be possible using a ( stop !!).
Gave a look and found :
http://www.15seconds.com/issue/020417.htm
It looks to be done at compile time by using or not the
IRequiresSessio nState, IReadOnlySessio nState interfaces so you could declare
this from your code behind. I tried, it works.
Strickly speaking you can't do this without touching web.config as it
doesn't seem you can tell that session is not required at all (likely the
"false" value allows to suppress the addition of those interfaces but you
have no way to do that if session are already enabled in the web config as
the absence of the directive will cause the appropriate interface to be
added for you).
So the best you could do for now would be :
- to suppress session in the web.config
- you can add session support by using IRequiresSessio nState or
IReadOnlySessio nState in your code behind file
You may want still to elaborate about what you are trying to do and why the
page directive doesn't fit...
--
Patrice
"coconet" <co*****@commun ity.nospama écrit dans le message de groupe de
discussion :
dr************* *************** ****@4ax.com...
Using ASP.NET 2.0, I want to use the code-behind to disable session
state (eg I do not want to put anything in the .aspx page template). I
also do not want to touch web.config.
How can I do this?
Thanks.