Reputation: 7812
I was debugging ASP.Net Core application and noticed strange thing about Environment.GetEnvironmentVariables() output. Environment.GetEnvironmentVariables() call gives me dictionary with 75 entries in it while environment variables configured at My Computer-> Properties->Environment variables shows very less entries i.e. around 20 entries. Please check screenshot below which shows both output from Environment.GetEnvironmentVariables() and environment variables from my computer -> properties.
So my question is from where Environment.GetEnvironmentVariables() is getting those additional entries. I am specifically interested in knowing source of entries which starts with "ASPNETCORE". Is it stored somewhere else. I am sure that these additional entries are not stored in my application's configuration file(s).
Upvotes: 2
Views: 165
Reputation: 58853
The environment variables not on your user or the machine are on the process.
Visual Studio sets some of them when you launch the application. You should be able to modify them in the project's Properties.
Right-click on your project in Solution Explorer and click Properties.
Open the Debug tab, and here you can add/edit/remove environment variables.
These environment variables are stored in Properties/launchSettings.json.
However, this answer does not completely answer the question, there are some environment variables coming from somewhere else as well. They might be set by ASP.NET Core itself / IIS module / IIS Express.
Upvotes: 1