【发布时间】:2015-11-03 23:06:16
【问题描述】:
我好像不太明白OWIN cookie认证中IsPersistent是如何工作的,下面的代码是使用IsPersistent:
var context = Request.GetOwinContext();
var authManager = context.Authentication;
var properties = new AuthenticationProperties { IsPersistent = isPersistence };
authManager.SignIn(properties, identity);
当用户选中/取消选中 Remember me(在后面使用 IsPersistent)时,我看不到区别,因为如果我关闭 Chrome 浏览器并再次打开它以访问网站,cookie .AspNet.ApplicationCookie 仍然存在并且即使我选中或取消选中Remember me,它也能让我进入。
我已经检查了link上IsPersistent的定义:
获取或设置身份验证会话是否跨多个请求保持。
但没有得到太多理解,因为我看到它仍然有效。
设置 OWIN cookie 身份验证的代码:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationMode = AuthenticationMode.Active,
AuthenticationType = ApplicationTypes.ApplicationCookie,
ExpireTimeSpan = TimeSpan.FromMinutes(30),
LoginPath = new PathString("/Account/LogOn")
});
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-5 owin