Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS doesn't use user environment variables

Tags:

asp.net

iis

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.

like image 270
Brad Gardner Avatar asked Mar 08 '23 21:03

Brad Gardner


1 Answers

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?

like image 153
Lex Li Avatar answered Mar 26 '23 06:03

Lex Li