PostBack beefore Session Check

Do not check PostBack before session

protected void Page_Load(object sender, EventArgs e)
{
    if (Session["login"] != null && Session["login"].ToString() == "1")
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }
    else
    {
        Response.Redirect("login.aspx");
    }
}

      

0


source to share


1 answer


It depends on what you are doing and normally I would say no.

The session expires between the time the page was loaded and the time at which the feedback occurred. Of course, they will have to sit on the page for a long time, but this can happen.



Check the session first, make sure the session information is always available.

+1


source







All Articles