Shouldn’t PostBack be checked 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'); } }
This depends on what you are doing, and typically I would say no.
It is possible for session to expire between the time that the page loaded, and the time that a postback happened. Granted they would have to sit on the page for quite a while, but it could happen.
Checking session first, ensures that the session information is always available.