简体   繁体   中英

DefaultAuthenticationTypes.ApplicationCookie persist after server reboot

I am using mvc 5 with external log in with facebook, but after every server reboot, the user would be logged out of the system. That defeats the purpose of oAuth? I can't find any properties to make them persist through reboots

this is how the startup.auth looks like..

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);

If the web.config file uses the default auto-generated settings, the server's encryption keys will change each time the web server restarts. To fix this the machineKey element needs to have fixed key values.

An online machineKey generator: http://aspnetresources.com/tools/machineKey

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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