会话不定期过期
你好朋友,
我制作了一个Web应用程序,在其中成功设置了成功的登录会话值后,我有一个登录页面,如
会话["user"] = txtusername.Text;
然后我有一个母版页,我正在该母版页上检查会话值,即
Hello friends ,
I Made a web application in which i have one login page after successful login session value is set like
Session["user"]=txtusername.Text;
Then I have one master page On which i am checking the session value i.e.
if (Session["user"] == null)
{
Session.Abandon();
Response.Redirect("Login_Master.aspx");
}
然后我有另一种数据输入形式,当我单击一个保存时,基本上就是母版页的子页面,但在填写所有必填字段后,它有时会重定向到登录页面,而不会保存数据并对其进行保存.
此应用程序在本地托管或调试时可以正常工作,但是在远程托管在Web服务器上时会出现此问题.
数据输入页面的编码如下所示:
then i have one other form for data entry which is basicaaly the child page of master page when i click one save but after filling all the required field it somtimes redirect to login page with out saving data and somtime it save.
this application is working when hosted or debug locally but this problem arises when it hosted on web server remotely.
coding for data entry page is shown below :
string accname = ddlaccname.SelectedValue.ToString();
string accman = ddlaccmanager.SelectedValue.ToString();
string currentdate = DateTime.Now.ToString("dd/MM/yyyy");
//string product = ddlproduct.SelectedValue.ToString();
string[] products = new string[ListBox1.Items.Count];
string[] productsname = new string[ListBox1.Items.Count];
int progress = Convert.ToInt32(ddlprogress.SelectedValue.ToString());
for (int i = 0; i < ListBox1.Items.Count; i++)
{
products[i] = ListBox1.Items[i].Value.ToString();
productsname[i] = ListBox1.Items[i].ToString();
}
string emp_id = Session["emp_id"].ToString();
string insert="insert query for data inserion";
string insert1="insert query 1 for data inserion";
SqlTransaction st;
con.Open();
st = con.BeginTransaction();
try
{
new SqlCommand(insert, con, st).ExecuteNonQuery();
new SqlCommand(insert1, con, st).ExecuteNonQuery();
for (int j = 0; j < ListBox1.Items.Count; j++)
{
string insert3="insert query 3 for data inserion";
new SqlCommand(insert3, con, st).ExecuteNonQuery();
}
st.Commit();
con.Close();
//SendMail();
Response.Redirect("LEAD_MASTER.aspx");
//Response.Redirect("LEAD_MASTER.aspx",
我不知道主要问题是什么,请针对我的会话超时默认设置为1Hour提出一些解决方案,这不是问题.
I don''t know what is the main problem please suggest some solution for that my session timeout by default is set to 1Hour which is not a problem .
嗨丹麦文,
请尝试以下链接:
http://www.abstraction.net/ViewArticle.aspx?articleID=74 [ ^ ]
会话超时警告和重定向 [
Hi danish,
Please try following links:
http://www.abstraction.net/ViewArticle.aspx?articleID=74[^]
Session Timeout Warning and Redirect[^]
1)确保您正在检查HttpContext.Current.Session(")
之类的会话
2)向您的主机咨询有关托管您的应用程序的IIS的设置.可能是IIS经常重置,也可能是您的应用程序经常在其中回收的应用程序池.
祝您好运
1)Make sure that you are checking the session like HttpContext.Current.Session("")
2) Check with your host about the setting of IIS hosting your app. May be the IIS is reset frequently or the app pool in which your app is being recycled frequently.
best luck
我认为这将是您服务器上的问题.尝试其他地方!再次遇到相同的问题吗?
i think it will be problem on your server.Try with somewhere else!! and are you getting same problem again ?