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

时间:2014-02-23 14:10:39

标签: c# .net asp.net-mvc-5 asp.net-identity owin

我正在使用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);

2 个答案:

答案 0 :(得分:0)

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

            await SignInAsync(user, isPersistent: false);

答案 1 :(得分:0)

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

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

相关问题