首页  电脑故障排除  病毒安全 电脑基础知识  硬件知识  软件应用知识  操作系统知识  编程程序

美国编程网址 日本编程网址 法国编程网址 德国编程网址 韩国编程网址 香港编程网址 台湾编程网址

您的位置:首页>>编程程序>>ASP应用

Session过期问题

 
Session过期问题
SessionState 的Timeout),其主要原因有三种。
一:有些杀病毒软件会去扫描您的Web.Config文件,那时Session肯定掉,这是微软的说法。
二:程序内部里有让Session掉失的代码,及服务器内存不足产生的。
三:程序有框架页面和跨域情况。
第一种解决办法是:使杀病毒软件屏蔽扫描Web.Config文件(程序运行时自己也不要去编辑它)
第二种是检查代码有无Session.Abandon()之类的。
第三种是在Window服务中将ASP.NET State Service 启动。
http://community.csdn.net/Expert/topic/3100/3100218.xml?temp=.4426386
还有可能就是你在测试期间改动了,网站的文件。
我测试过没有问题!测试程序如下:
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();
??}
所有的代码都是Global里面的

查看上一页  返回分类首页 返回96PC首页  查看下一页

  版权所有:电脑知识大全 网站备案:粤ICP备07031496号  联系我们

友情链接:母婴知识  外贸商务网  娱乐频道  汽车维修知识  股票入门知识  游戏攻略秘籍  本站空间由安信网络提供