简体   繁体   中英

ASP.Net Core application and Environment.GetEnvironmentVariables() strange behavior

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 ie 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).

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.

VS 项目属性中的环境变量

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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