ASP.net中的会话过期刷新任何页面后

时间:2013-08-02 09:47:16

标签: c# asp.net

我有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");
        }

0 个答案:

没有答案