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