C# 如何使用Owin身份验证为前端和后端设置Cookie超时
我有一个使用ASP NET MVC 5的项目,它由两部分组成:后端和前端。我使用OWIN身份验证。如何分别为前端和后端设置Cookie超时 目前,我只为整个站点设置超时C# 如何使用Owin身份验证为前端和后端设置Cookie超时,c#,asp.net-mvc,asp.net-mvc-5.2,C#,Asp.net Mvc,Asp.net Mvc 5.2,我有一个使用ASP NET MVC 5的项目,它由两部分组成:后端和前端。我使用OWIN身份验证。如何分别为前端和后端设置Cookie超时 目前,我只为整个站点设置超时 app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, Logi
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/LoginAdmin"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser, string>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
getUserIdCallback: (claim) => claim.GetUserId())
},
ExpireTimeSpan=TimeSpan.FromHours(4)
});
app.UseCookieAuthentication(新的CookieAuthenticationOptions
{
AuthenticationType=DefaultAuthenticationTypes.ApplicationOkie,
LoginPath=新路径字符串(“/Account/LoginAdmin”),
Provider=新CookieAuthenticationProvider
{
OnValidateIdentity=SecurityStampValidator.OnValidateIdentity(
validateInterval:TimeSpan.FromMinutes(30),
regenerateIdentityCallback:(管理器,用户)=>user.GenerateUserIdentityAsync(管理器),
getUserIdCallback:(声明)=>claim.GetUserId()
},
ExpireTimeSpan=时间跨度从小时(4)
});