IIS doesn’t use user environment variables

I’m deploying a .NET Core application twice to the same server, once for QA, and once for Production. Currently I have each one of them using a different local user to run the IIS App Pool and have set the ASPNETCORE_ENVIRONMENT variables to “qa” and “production” accordingly.

This doesn’t appear to work, both sites run the production configuration which I understand is the default.

Things I’ve looked at so far:

  1. I can log in as each of the users, and the variables are set
    correctly.
  2. There is no system level env var set, though the user level vars are supposed to override it if there was.
  3. I can see the processes running as the correct users in the task manager.
  4. I have restarted the entire system after setting the env vars

It just appears that .NET is ignoring the environment variable.

Has anyone else managed to get user level env vars working with a .NET core deployment?

Additional Info: I can set ASPNETCORE_ENVIRONMENT at the system level, and both sites pick it up and run with it. Doing it without a system variable simply doesn’t work.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

If you want to use user specific environment variables, then the application pool setting LoadUserProfile should be set to true (false is the default),

What exactly happens when I set LoadUserProfile of IIS pool?


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x