How to Check whether Session is Expired or not in asp.net

前端 未结 8 2096
情话喂你
情话喂你 2020-12-03 01:03

I\'ve specified the session timeout in web.config file. When the session is timeout I\'m not getting redirect to the login page but I am getting an error saying object refer

8条回答
  •  北海茫月
    2020-12-03 01:48

    Here I am checking session values(two values filled in text box on previous page)

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["sessUnit_code"] == null || Session["sessgrcSerial"] == null)
        {
            Response.Write("");
        }
        else
        {
    
            lblUnit.Text = Session["sessUnit_code"].ToString();
            LblGrcSr.Text = Session["sessgrcSerial"].ToString();
        }
    }
    

提交回复
热议问题