Session End in ASP.net MVC

前端 未结 4 741
执念已碎
执念已碎 2020-12-07 21:38

I am placing user data in the session then passing it to viewdata to view on a page. Now when my user walks away from his computer for a while, the session ends and the data

4条回答
  •  感情败类
    2020-12-07 21:59

    I use some Javascript in my MasterPage to redirect the user (after a prompt to renew the session) to the logout action. It uses an AJAX request back to the Home page of the app to refresh the server side session window when the user clicks the button in the dialog to extend the session. Relies on jQuery and jQuery UI for the dialog.

     <% if (this.Request.IsAuthenticated)
        {
            int sessionDialogWait = 2 * 60 * 1000 - 60 * 500; // ms = 1.5 minutes
            int sessionTimeout = 28 * 60 * 1000; // ms = 28 minutes
            if (ViewData["sessionTimeout"] != null)
            {
                sessionTimeout = ((int)ViewData["sessionTimeout"] * 60 - 120) * 1000;
            }
    %>  
    
    <% } %>
    
    
    

提交回复
热议问题