Session Expiration issue

Source: Internet
Author: User
Tags datetime server memory
sessionstate timeout), the main reasons are three kinds.


: Some kill virus software will go to scan your Web.config file, at that time session affirmation drops, this is Microsoft's saying.


Two: Inside the program has let the session loses the code, and the server memory is not enough to produce.


Three: The program has frames page and cross domain situation.


The first solution is to make the virus-killing software screen scan Web.config file (the program does not edit it when it is running)


the second is to check whether the code has Session.Abandon () or something.


the third is to start the ASP.net State Service in the window service.


http://community.111cn.net/Expert/topic/3100/3100218.xml?temp=.4426386


may also be the file that you changed during the test, the website.


I tested no problem! The test procedure is as follows:


protected void Application_Start (Object sender, EventArgs e)


?? {


??? SqlConnection con = new SqlConnection ("server=localhost;database=yourdatabase;uid=sa;pwd=;");


??? SqlCommand cmd = new SqlCommand (string. Format ("INSERT INTO table1 (c) VALUES (' {0} ')", "Application_Start" +datetime.now.tolongtimestring () + "Application ID" + Application.tostring ()), con);


??? Con. Open ();


??? Cmd. ExecuteNonQuery ();


??? Con. Close ();


??}


?


?? protected void Session_Start (Object sender, EventArgs e)


?? {


??? SqlConnection con = new SqlConnection ("server=localhost;database=yourdatabase;uid=sa;pwd=;");


??? SqlCommand cmd = new SqlCommand (string. Format ("INSERT INTO table1 (c) VALUES (' {0} ')", "Session_Start" +datetime.now.tolongtimestring () + "sessionid=" + Session.SessionID), con);


??? Con. Open ();


??? Cmd. ExecuteNonQuery ();


??? Con. Close ();


??}


?? protected void Application_BeginRequest (Object sender, EventArgs e)


?? {


??? SqlConnection con = new SqlConnection ("server=localhost;database=yourdatabase;uid=sa;pwd=;");


??? SqlCommand cmd = new SqlCommand (string. Format ("INSERT INTO table1 (c) VALUES (' {0} ')", "Application_BeginRequest" +datetime.now.tolongtimestring ()), con);


??? Con. Open ();


??? Cmd. ExecuteNonQuery ();


??? Con. Close ();


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.