By default, sessions are disabled for the entire site, but a page is disabled.

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.