简体   繁体   English

.net用户密码在Windows 10上不起作用

[英].net User Secrets not working on Windows 10

I'm running into a problem where UserSecrets returns my secret on Mac, but not windows. 我遇到了一个问题,其中UserSecrets在Mac而不是Windows上返回我的秘密。 I followed https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?tabs=visual-studio 我遵循了https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?tabs=visual-studio

On windows, when I try to get the secret: Configuration["ConnectionStrings:Production"] it returns null. 在Windows上,当我尝试获取机密时: Configuration["ConnectionStrings:Production"]它返回null。

I have the secrets.json file saved at C:\\Users\\username\\AppData\\Roaming\\Microsoft\\UserSecrets\\<userSecretsId> 我将secrets.json文件保存在C:\\Users\\username\\AppData\\Roaming\\Microsoft\\UserSecrets\\<userSecretsId>

I can't figure out why it won't work on Windows, while it works perfectly on Mac. 我无法弄清楚为什么它不能在Windows上运行,而在Mac上却可以完美运行。 Any help is greatly appreciated. 任何帮助是极大的赞赏。

It might be worth noting this is on a Windows Server 可能值得注意的是,这是在Windows Server上

I'm wondering now if %AppData% is different in the context of IIS? 我现在想知道%AppData%在IIS上下文中是否不同?

I think this thread is the right direction but none of the solutions work for me 我认为此线程是正确的方向,但是没有一种解决方案对我有用

The IIS ApplicationPoolIdentity should have it's own user profile folder, which is not the same as your user folder. IIS ApplicationPoolIdentity应该具有自己的用户配置文件文件夹,该文件夹与您的用户文件夹不同。

To find it, navigate to C:\\Users, and you should see folders named for the application pools, so for an App Pool named ".NET v4.5" there should be a user folder called ".NET v4.5". 要找到它,请导航到C:\\ Users,您应该看到为应用程序池命名的文件夹,因此对于名为“ .NET v4.5”的应用程序池,应该有一个名为“ .NET v4.5”的用户文件夹。 Under that folder you should be able to follow the rest of your breadcrumb through the AppData folder and create the "\\AppData\\Roaming\\Microsoft\\UserSecrets" folder if it doesn't exist. 在该文件夹下,您应该可以通过AppData文件夹跟踪其余的面包屑,并创建“ \\ AppData \\ Roaming \\ Microsoft \\ UserSecrets”文件夹(如果不存在)。

If that doesn't work or if you don't see user folders for the Application Pools, open up IIS Manager, select the Application Pool you're running under, then open Advanced Settings (link on the right hand side) 如果这不起作用,或者您没有看到“应用程序池”的用户文件夹,请打开IIS管理器,选择要在其下运行的应用程序池,然后打开“高级设置”(右侧的链接) 高级设置

After opening the Advanced Settings, scroll down to the Process Model section and you should see a configuration for "Load User Profile", and make sure the value is set to True. 打开“高级设置”后,向下滚动到“流程模型”部分,您应该看到“加载用户配置文件”的配置,并确保将值设置为True。 Default is true in Windows 10, but depending on how you've done config prior versions of Windows defaulted to False which would make the secrets not available. 在Windows 10中,默认值为true,但是取决于您的配置方式,Windows的先前版本默认为False,这会使机密不可用。

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

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