0
我想通过管理后端为ASP.NET身份配置更改Session Timeout
的IAppBuilder
。如何在应用程序的任何位置设置会话超时
这个想法是摆脱IIS手动重置,只是在数据库中配置会话超时。
换句话说,我们可以在ASP.NET MVC App的不同位置访问CookieAuthenticationOptions
吗?
例如,我们可以在HomeController
这样做吗? 有没有办法做到这一点?
STARTUP.AUTH.CS
public void ConfigureAuth(IAppBuilder app)
{
// It goes from Database
var sessionTimeout = Convert.ToInt32(SysConfigView.GetSysConfig().SessionTimeout);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
ExpireTimeSpan = TimeSpan.FromMinutes(sessionTimeout),
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
CookieName = ".MyApp_Authentication",
SlidingExpiration = true
});
// There is other code...
}
ASP.NET身份不使用web.config来管理会话超时。我需要在数据库中保持会话超时,并随时将其全部应用于整个应用程序。 – 2014-10-20 13:16:01