Repository navigation
Description
I tried this hosting in local IIS and the local secrets were not loaded. When I read the location of the local secrets - %APPDATA%\Microsoft\UserSecrets<user_secrets_id>\secrets.json - I took a punt and changed to IIS Express and it worked.
First thing I tried was adding read permissions to IIS worker process to the above directory. This didn't work and I realised that the %appdata% was likely to be different for the IIS worker process anyway.
Before reaching for sysinternals filemon - I googled and found that someone else had already done this..
Basically it seems to look in the directory of the application (project) and sure enough if I put my secrets (file) there it works.
Not sure if it also looks in - %APPDATA%\Microsoft\UserSecrets<user_secrets_id>\secrets.json - to be honest I didn't even check if APPDATA is set for the IIS worker process.
Here's where I got my solution - https://stackoverflow.com/questions/49597408/asp-net-core-2-web-application-isnt-loading-user-secrets-when-debugging-iis-web
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 9c99993c-c983-6fda-6c3a-ce4ec8c1d5db
- Version Independent ID: ba688ac2-e90e-fce5-f60d-40c2553c3efd
- Content: Safe storage of app secrets in development in ASP.NET Core
- Content Source: aspnetcore/security/app-secrets.md
- Product: aspnet-core
- Technology: aspnetcore-security
- GitHub Login: @Rick-Anderson
- Microsoft Alias: scaddie
Activity
guardrex commentedon Dec 27, 2019
Hello @stuartm9999 ... Thus far, this is an unsupported scenario outside of perhaps the dev-time support with IIS and VS (as covered by that doc). Recommend that we leave this to Stack Overflow to cover.
stuartm9999 commentedon Dec 27, 2019
I guess I'm one of the few still using IIS. I'm old and have been caught out on a few occasions by the differences between IIS and IIS express. I believe Azure App service is running IIS so I like to keep close to production - though in this case that desire is not relevant.
Anyway more info.
Further investigation proved that it works as advertised - using %APPDATA%\Microsoft\UserSecrets<user_secrets_id>\secrets.json but you
If it can't find or read the C:\WINDOWS\system32\config\systemprofile\AppData\Roaming<UserSecretsId> then it defaults to the web application directory. I've updated stack overflow as you suggested.
Do you think its worth updating the documentation here to simply state that for IIS you need to find the APPDATA environment setting and set the permissions? A simple warning might do?
Rick-Anderson commentedon Dec 27, 2019
I'll add a link to this issue to the doc.
Rick-Anderson commentedon Dec 28, 2019
@stuartm9999 thanks for the follow up. I like testing against IIS too. Another advantage is it allows remote access to the web app.
stuartm9999 commentedon Dec 30, 2019
Thanks @Rick-Anderson - I had a quick glance at your proposed changes and they seem to make everything clear.
Have a great new year.
darl0026 commentedon Feb 3, 2021
This is ridiculous, this needs to be fixed. Allowing your website access to a system folder is unacceptable
KaptenJon commentedon Mar 30, 2022
If you have an custom set Identity for the application pool: