From the course: Learning ASP.NET Core MVC

Unlock the full course today

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

Use custom configuration

Use custom configuration

From the course: Learning ASP.NET Core MVC

Start my 1-month free trial

Use custom configuration

- [Instructor] Earlier I showed you this conditional statement right here on line 25 that determines whether or not to enable the developer diagnostics page. Currently, this conditional setting is driven off a special environment variable that ASP.NET Core looks for as I showed in the previous video. Now there's nothing wrong with this approach to turn things on and off based on whether we're in a development mode or not but personally I like to be able to turn specific features on and off using their own configuration setting. So, in this video, I'll use ASP.NET Core's configuration library to create a configuration setting just for this feature. In fact, ASP.NET Core has already created and populated a configuration object for me. I just need to access it. And the easiest way to access it is to request it in the Startup class's constructor. To do this, I'll first create the constructor and then I'll include a parameter of the type IConfiguration which lives in the…

Contents