We can setup different environments while developing an application in .net core.
When we first create an application in .net core using the web api template, we have two different profiles available in the launchSettings.json.
- IIS Express
- {Name of the project}
Note: launchSettings.json file is only available at the time of development.
Lets try to understand this file.
In the profile section we have two profiles available.
IIS Express
As we can see commandName is set to IISExpress, and in the environment varialble section we have ASPNETCORE_ENVIRONMENT variable set to Development.{Name of the Project}
Here we can see commandName is set to Project, and in the environment varialble section we have ASPNETCORE_ENVIRONMENT variable set to Development.
We can select any of these profile to run our application.
If commandName is set to IISExpress, then the application will be launched using IISExpress and if the commandName will be set to Project, then the application will be launched using kestrel server along with a reverse proxy server.
And as in both the cases ASPNETCORE_ENVIRONMENT set to development, so the environment will be development. We can check for different environment in the startup.cs file using various extension methods.
And if no value is set for ASPNETCORE_ENVIRONMENT variable in launchSettings.json, then it will look in the System Environment Variable and if it is also not set there, then the value will be production by default.
Top comments (0)