Asp.net session expiry redirect to login page

前端 未结 5 1815
一整个雨季
一整个雨季 2020-12-20 08:28

What is the best way to redirect to the login page when the session expires. I\'m using

sessionState mode=\"InProc\"

Can I set this in the

5条回答
  •  没有蜡笔的小新
    2020-12-20 08:33

    Bellow Answer is the best example ever and ever......

    Better to try this way:

    Page.ClientScript.RegisterStartupScript(Me.GetType, "TimeoutScript", "setTimeout(""top.location.href = '~/Login.aspx'""," & ConfigurationManager.AppSettings("SessionTimeoutMilliseconds") & ");", True)
    

    You'll notice that I have the actual milliseconds stored in my web.config file so that I can adjust the timeout length as needed.

    Using this, combined with the typical Session_End event in the Global.asax file makes a pretty clean way of handling session timeouts in my web apps.

    Regards, Nagaraju R || Dell PerotSystems ||

提交回复
热议问题