Exceptions provide great good troubleshooter to developers.
But the technical details behind it are complex, the performance loss will also make it easier for .net core web app is villain attacks.
So we have to learn to use environment variables, environment variables, some of the control logic
When an exception pages in the development environment, errors, jump to the developer to see
Jump to the error page to the user to see when in the production environment, errors,
.net core web app environment can be set up on your computer,
After you set the environment variable computer to restart visual studio to take effect.
LaunchSettings.json may be provided, the set may not be the same time setting, greater than ambient launchSettings.json configuration variables on the computer
When not set, the default product
.net core web app supports three default environment
1. Development Environment Development
2. Presentation Staging environment
3. Production environment Production
In the program can use dependency injection IHostingEnvironment
IHostingEnvironment.IsDevelopment()
IHostingEnvironment.IsStaging()
IHostingEnvironment.IsProductiont()
In addition to these three environment variables may be arbitrary string calculation own environment variables such as environmental variables heiheihei
IHostingEnvironment.IsEnvironment("heiheihei")
In addition, the use of
IHostingEnvironment.EnvironmentName
You can get the current environment variable strings.