By default, sessions are disabled for the entire site, but not for a page.
The following is an incorrect practice:
The Web. config of the entire site is set:
<Configuration>
<System. Web>
<Sessionstate mode = "off"/>
</System. Web>
</Configuration>
On the page for separate use of sesssion, Set
<% @ Page enablesessionstate = "true" %>
This method is incorrect and you will find that it is still an error:
The session status can be used only when the enable session status is set to true in the configuration file or page command.
Or:
Session state can only be used when enablesessionstate is set to true, either in a configuration file or in the page directive. please also make sure that system. web. sessionstatemodule or a custom session state module is wrongly ded in the <configuration >\< system. web> \
The reason is described later.
The correct method is
Do not use the following configuration for sessionstate in the web. config section,
<Sessionstate mode = "off"/>,
It uses several other configuration methods. (The default configuration is inproc. )
Then, set it in the web. config file.
<Configuration>
<System. Web>
<Pages enablesessionstate = "false"/>
</System. Web>
</Configuration>
In this way, the session is not opened on the page of the entire site by default.
Use the following page settings on the page you need
<% @ Page enablesessionstate = "true" %>
Or, in the directory where you want to open the session, set a web. config
<Configuration>
<System. Web>
<Pages enablesessionstate = "true"/>
</System. Web>
</Configuration>
Cause analysis:
<Sessionstate mode = "off"/> indicates that the session is disabled for the entire site. You cannot perform special column processing.
In addition, you can view the selected session status by accessing the value of the system. Web. sessionstate. httpsessionstate. mode attribute.
The above knowledge points apply not only to Asp.net 1.0 1.1 but also to 2.0
MATERIALS:
How to: Disable ASP session Status in ASP. NET
Http://support.microsoft.com /? SCID = KB; ZH-CN; 306996 & spid = 548 & SID = 89