繁体   English   中英

服务器重启后,DefaultAuthenticationTypes.ApplicationCookie仍然存在

[英]DefaultAuthenticationTypes.ApplicationCookie persist after server reboot

我正在使用mvc 5与facebook进行外部登录,但每次重启服务器后,用户都将退出系统。 这违背了oAuth的目的? 我找不到任何属性,让它们通过重新启动持续存在

这就是startup.auth的样子......

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Account/External"),
    ExpireTimeSpan = new TimeSpan(30, 0, 0, 0),
    SlidingExpiration = true
});

app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

是的,所以相当于记住我的密码登录不是默认模板中的一个选项,基本上你可以通过在ExternalLoginCallback中将isPersistent更改为true来做到这一点

            await SignInAsync(user, isPersistent: false);

如果web.config文件使用默认的自动生成设置,则每次Web服务器重新启动时,服务器的加密密钥都将更改。 要解决此问题, machineKey元素需要具有固定的键值。

在线machineKey生成器: http//aspnetresources.com/tools/machineKey

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM