Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# DefaultAuthenticationTypes.ApplicationOkie在服务器重新启动后保持_C#_.net_Asp.net Mvc 5_Asp.net Identity_Owin - Fatal编程技术网

C# DefaultAuthenticationTypes.ApplicationOkie在服务器重新启动后保持

C# DefaultAuthenticationTypes.ApplicationOkie在服务器重新启动后保持,c#,.net,asp.net-mvc-5,asp.net-identity,owin,C#,.net,Asp.net Mvc 5,Asp.net Identity,Owin,我正在使用MVC5与facebook进行外部登录,但每次服务器重新启动后,用户都会从系统中注销。这违背了oAuth的目的?我找不到任何属性使它们在重新启动时保持不变 这就是startup.auth的外观 app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath =

我正在使用MVC5与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
生成器:

我已将其设置为true,但它仍然不“记住我”这会引起任何安全问题吗?不会(但是
machineKey
属性应始终使用您的IIS版本支持的最安全的算法值)。这是web场中用于确保所有服务器使用相同密钥集的机制。感谢devstuff,它现在可以工作,所以如果密钥遭到破坏,我们必须手动更改它?面临“所有用户都已注销”的问题?没错。如果您是一个更大的开发团队的一员,您可能希望有单独的调试和生产设置,生产只对进行部署的人可用。这将最小化任何曝光窗口。