ASP.NET Automatic logout

后端 未结 5 1204
我在风中等你
我在风中等你 2021-01-01 06:12

I am doing a group project with 4 other people. We are designing a job kiosk in ASP.NET in MVC4 with embedded c#.

I am working on having the system log the user out

5条回答
  •  -上瘾入骨i
    2021-01-01 06:54

    If you need to have them automatically logged out, start with Linus Caldwell's suggestion of setting the web.config session timeout. His example shows 30 minutes, so you would just change it to 10. The user won't know that they're logged out, though, until they actually try to request some server resource. To have that happen automatically, you can go a couple of ways. Both of these ways involve automatically refreshing the page after the timeout period has expired. One way is to use a javascript timer. The other is to add a refresh header to each page.

    
    

    The other way would be in your global.asax:

    protected void Application_BeginRequest()
    {
        Response.Headers.Add("Refresh", Convert.ToString(Session.Timeout * 11));
    }
    

提交回复
热议问题