aspnetboilerplate共享cookie对services.AddDataProtection()无效

问题描述 投票:0回答:1

我有以下场景:

Server A:abpWeb; 
Server B:abpWeb;

A和B基于MyCompanyName.AbpZero模板,abp。净核心版本3.1.1; aspnetboilerplate

浏览器访问A:abpWebB:abpWeb。但登录后,cookie共享无效。

答:User.Identity?。浏览器访问后,IsAuthenticated等于true A:登录;

但是在浏览器上刷新B:/ index,B:User.Identity?。IsAuthenticated等于false;

A和B的浏览器域相同。

我使用ASP.NET核心身份创建了两个新的ASP.NET Core 2.0 MVC应用程序,使用AddDataProtection正常共享cookie是可以的。

我提到: https://docs.microsoft.com/en-us/aspnet/core/security/cookie-sharing?tabs=aspnetcore2x

我在网上搜索了很长时间。但没用。请帮助或尝试提供一些如何实现这一点的想法。提前致谢。

aspnetboilerplate .net-core-2.0
1个回答
0
投票

加密/解密您的cookie的密钥可能正在尝试写入无效的文件夹。

默认情况下,AddDataProtection尝试将这些键写入:%LOCALAPPDATA%\ASP.NET\DataProtection-Keys

只要有一个环境变量用于创建密钥路径,您就需要将以下配置文件设置为true。

请在这里看到我的另一个答案:IIS - AddDataProtection PersistKeysToFileSystem not creating

修复:在%WINDIR%\System32\inetsrv\config\applicationHost.config内设置setProfileEnvironment=true。我想你也必须重启IIS。

© www.soinside.com 2019 - 2024. All rights reserved.