In this video, learn how to write code that can detect whether the application is running in a development, staging, or production environment. Nate shows how to check the environment at runtime in the Startup class, and explains how ASP.NET Core knows which environment it's running in.
- [Instructor] It's often necessary to write code…that behaves differently depending on which environment…your application is running in.…For example, you may need to connect to a test database…in your development or staging environment;…but when you deploy the application to production,…you wanna connect to your production database.…In Startup.cs, the Ihosting environment object lets you…check at run time which environment your code is running in.…In the default MVC template, the developer exception page…and browser link are automatically enabled…in development mode, but are disabled if the app is running…in a staging or production environment.…
You can add any checks you need here…for your application in Startup.cs.…ASP.NET Core determines which environment it's running in…by examining an environment variable…called ASP.NETCORE_Environment.…If you go to the project properties panel and the debug tab,…you can see that when you run the application…inside of Visual Studio, this environment variable…is automatically set to development.…
- Setting up your ASP.NET project
- Setting up IIS
- Creating an IIS site and app pool
- Publishing your app with Visual Studio or the command line
- Deploying to Azure
- Deploying to Linux
- Deploying with Docker
Skill Level Intermediate
1. Get Started
2. Deploying to IIS
3. Deploying to Azure
Get started with Azure1m 4s
4. Deploying to Linux
5. Deploying with Docker
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.