ASP.NET MVC Session Expiration

前端 未结 6 2016
孤街浪徒
孤街浪徒 2021-01-01 21:51

We have an internal ASP.NET MVC application that requires a logon. Log on works great and does what\'s expected. We have a session expiration of 15 minutes. After sitting on

6条回答
  •  情话喂你
    2021-01-01 22:26

    Specifically, I don't know that there are any best practices regarding it, but I'm doing this right now for our app. We've opted for a client-side solution where we output the Session timeout value into some javascript in the master page, and calculate when the session will expire.

    5 minutes before-hand, we pop up a modal dialog box saying "Are you still there?" with a countdown timer. Once the timer hits 0:00, we redirect the browser to the login page.

    It's implemented with a minimal amount of javascript to do the time and timer calculations, and a simple .ashx handler that will refresh the session if the user clicks "I'm back!" on the dialog box before the session expires. That way if they return in time, they can refresh the session without any navigation.

提交回复
热议问题