From the course: Deploying ASP.NET Core Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Write code for development and production

Write code for development and production

From the course: Deploying ASP.NET Core Applications

Start my 1-month free trial

Write code for development and production

- [Instructor] It's often necessary to write code that behaves differently depending on which environment your application is running in. For example, you might connect to a test database in your development or staging environment, but when you deploy the application in production, you wanna use a different string to connect to your production database. In Startup.cs, the IHostingEnvironment object lets you check at run time which environment your application is running in. In the default MVC template, this is used to enable the developer exception page in development mode, but turn on a different exception handler in production. You can add any checks you need for your application here in Startup.cs. IHostingEnvironment determines which environment it's running in by examining an environment variable called ASPNETCORE_ENVIRONMENT. If you go to the project properties window in the Debug tab, you can see that it's set to development when you run the application from within Visual…

Contents