Make sure that the System. Web. SessionStateMod or custom session Status Module is included in the \ section of the application configuration.

Source: Internet
Author: User

When designing Asp.net using VS2010, the following occurs:

The session status can be used only when enableSessionState is set to true in the configuration file or Page command. Make sure that the System. Web. SessionStateMod or custom session Status Module is included in the \ section of the application configuration.

Google does not solve many solutions (all of these solutions are modifying Web. config)

But who told me that my project used the class library and page under the VS2005 project? So I re-built the project and added the original file, there were no problems during the addition process until after compilation and running (the operation is normal), the design was re-opened, and the problem encountered again, which was hard to understand. By accident, we found that some files are designed normally. After comparison, we found that the pages that cannot be designed normally are inherited from the BasePage and the BasePage is inherited from the System. web. UI. page, so we can remove the inheritance, regenerate it, and re-open VS. The design is normal.

But why does the BasePage work normally in VSS005?

Later, it was tested because Response. Redirect ("~ /Logout. aspx ")

Changed to: System. Web. HttpContext. Current. Response. Redirect ("~ /Logout. aspx ").

However, the problem is not solved, and new problems arise: the error message "error response during control creation is unavailable in this context" and "error occurred while creating the control. The object reference is not set to the instance of the object" are displayed ".

Solution:

Protected override void OnInit (EventArgs e)
{
If (System. Web. HttpContext. Current! = Null)
{
......
Base. OnInit (e );
}
}

I also found that as long as Page is used in the method called in Oninit, we need to make this judgment. Therefore, we recommend that you add this to the Oninit method as long as it is used. Otherwise, the problem may occur.

I initialized the user control in Oninit today. I want to use System in the user control. web. httpContext. current only uses the page. clientScript. registerStartupScript, so it is assumed that the Page is used.

 

 


From: http://hi.baidu.com/pp_sjh/blog/item/88f004a361ac31b8cbefd0d2.html

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.