Follow by Email

Wednesday, April 17, 2013

Handle Session Timeout in an application and redirect to custom error page

How to Handle Session Timeout in an application and redirect to custom error page.

By Default the Session timeout occurs after 20 Mins. To change the Timeout value you can change it in the webconfig file of the application as <sessionstate timeout="30"/>


Public Sub issessionvalid()

        If IsNothing(Trim(Session("YourSessionKeyword"))) Or Trim(Session("YourSessionKeyword")) = "" Or  Trim(Session("YourSessionKeyword")).Length = 0 Then

            'Response.Write("<script>parent.location.href=('CustomErrorPage.aspx');</script>")
            'Response.Redirect("CustomErrorPage.asp")
            Response.Redirect("CustomErrorPage.aspx")

       End If
     
End Sub