Session Expiration issue

Source: Internet
Author: User
Tags format config datetime insert server memory
session| problem sessionstate timeout), its main reasons are three kinds.
One: 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 session loses the code, and the server memory is insufficient to produce.
Third: The program has frames page and cross domain situation.
The first solution is to make the virus-killing software screen scan the web.config file (not to edit it when the program is running)
The second is to check whether the code has Session.Abandon () or not.
The third is to start the ASP.net State Service in the window service.

Http://community.csdn.net/Expert/topic/3100/3100218.xml?temp=.4426386
It is also possible that you changed the file during the test, the website.


I've tested it, 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 ();

??}

?? protected void Application_EndRequest (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_EndRequest" +datetime.now.tolongtimestring ()), con);
??? Con. Open ();
??? Cmd. ExecuteNonQuery ();
??? Con. Close ();

??}

?? protected void Application_AuthenticateRequest (Object sender, EventArgs e)
?? {

??}

?? protected void Application_Error (Object sender, EventArgs e)
?? {

??}

?? protected void Session_End (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_End" +datetime.now.tolongtimestring () + "sessionid=" + Session.SessionID), con);
??? Con. Open ();
??? Cmd. ExecuteNonQuery ();
??? Con. Close ();


??}

?? protected void Application_End (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_End" +datetime.now.tolongtimestring ()), con);
??? Con. Open ();
??? Cmd. ExecuteNonQuery ();
??? Con. Close ();


??}

All the code is in global.




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.