2
看起來下面的代碼在ASP.NET身份中不再起作用了嗎? 這是正確的嗎?Session.SessionTimeout在ASP.NET標識中被棄用
的Global.asax
protected void Session_Start(object sender, EventArgs e)
{
Session.Timeout = 5; // It has no impact to Session
}
而這個代碼僅定義會話超時。
STARTUP.AUTH.CS
public void ConfigureAuth(IAppBuilder app)
{
var sessionTimeout = 20; //
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
ExpireTimeSpan = TimeSpan.FromMinutes(sessionTimeout),
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
CookieName = ".MyApp1_Authentication",
SlidingExpiration = true
});
}
你不混合會話超時和cookie到期時間? – trailmax 2014-10-20 14:50:31
@trailmax可能......我認爲他們必須平等,對吧? – 2014-10-20 15:22:43
很大程度上取決於您想要實現的目標。 Cookie超時是cookie在瀏覽器中的存儲時間,身份驗證到期取決於此。會話壽命是指與當前訪問相關的用戶數據存儲在服務器上的時間。會話超時和cookie到期時間範圍相同是有意義的,但他們不必這樣做。那麼你想要做什麼? – trailmax 2014-10-20 15:49:36