我的 asp.net 应用程序一直运行良好,直到昨天。现在,如果我刷新两次,如果我第三次刷新页面,那么会话即将到期,并且每个表单都会发生这种情况
if (!IsPostBack)
{
Int32 id = 0;
try
{
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
MODEL.UsersCollection allUSers = new BLL.Users().Designation(Session["User"].ToString());
for (int i = 0; i <= allUSers.Count - 1; i++)
{
Session["Desig"] = allUSers[i].Type.ToString();
Session["DesigID"] = allUSers[i].DesigID.ToString();
Session["UserID"] = allUSers[i].ID.ToString();
Session["Name"] = allUSers[i].FirstName.ToString();
if (allUSers[i].Photo != null && allUSers[i].Photo != "")
Session["Photo"] = "~/User_Photos/" + allUSers[i].Photo.ToString();
else
Session["Photo"] = "";
}
lblWelcome.Text = "Welcome " + Session["Name"].ToString() + " ! " + String.Format("{0:dddd, MMMM d, yyyy}", System.DateTime.Today);
if (Session["Photo"].ToString() != "")
ImageUser.ImageUrl = Session["Photo"].ToString();
}
catch
{
id = 1;
}
if (id == 1)
{
Response.Redirect("logout.aspx");
}