Setting IHostingEnvironment.IsDevelopment as True in an ASP.NET 5 Application

Wondering why IHostingEnvironment.IsDevelopment returns false even when you are on you development machine? I did indeed wonder and here is why :)
2015-09-13 15:35
Tugberk Ugurlu

I am now in Frankfurt, sipping my coffee in a Starbucks shop and enjoying its rubbish internet connection (as usual). I have just thrown away 10 minutes from my life by trying to figure out why my ASP.NET 5 application wasn't showing the error page. So, I wanted to write this quick and dirty blog post for people who will potentially have the same problem :)

Here is the piece of code I have inside the Configure method of my Startup class:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    // ...

    // Add the following to the request pipeline only in development environment.
    if (env.IsDevelopment())
        // Add Error handling middleware which catches all application specific errors and
        // send the request to the following path or controller action.

    // ...

So, I should see the beautiful and detailed error page when I am in development. However, all I get is nothing but an empty response body when I run the application:



With a little bit of digging, I remembered that your environment is being determined through an environment variable which is ASPNET_ENV. Setting this to Development will return true from IHostingEnvironment.IsDevelopment. Also, the IHostingEnvironment.EnvironmentName will get you the value of this environment variable. You can set this environment variable per process, per user or per machine. Whatever floats your boat. I have set this for process on windows with the below script and I was able to get the lovely error page:

set ASPNET_ENV=Development



When you are on Visual Studio 2015, you can handle this better by adding a launchSettings.json file as here. VS will pick this up and set the environment variable for IIS Express process.


by Jimmy on Friday, Oct 09 2015 09:10:02 +00:00
This was useful, thanks for the tip
Alexander Batishchev
by Alexander Batishchev on Sunday, Dec 27 2015 03:52:28 +00:00
I'd use SETX to set it permanently.
Escorts in Amritsar
by Escorts in Amritsar on Friday, Aug 05 2016 12:41:48 +00:00
It's a helpful about Hosting. this article helps to create the hosting environment.
Escorts in Amritsar
by Escorts in Amritsar on Friday, Aug 05 2016 12:42:07 +00:00
It's a helpful about Hosting. this article helps to create the hosting environment.
Independent Call Girls Bangalore
by Independent Call Girls Bangalore on Thursday, Aug 25 2016 09:29:37 +00:00
This is awesome hosting website, but searching escorts so visit on our site.
Bold Call Girls in Chandigarh
by Bold Call Girls in Chandigarh on Thursday, Aug 25 2016 09:41:55 +00:00
Wonderful site, we can know about hosting environment. thanks for share that..
Sakshi Ahuja
by Sakshi Ahuja on Friday, Sep 02 2016 11:50:20 +00:00
I am very appreciate by this.I am Sakshi Ahuja, a passionate Delhi model girl living in the middle of Delhi city.
Delhi Escorts
by Delhi Escorts on Thursday, Sep 08 2016 19:09:46 +00:00
Riya Chaudhary a highly efficient and a very well-organized Independent Delhi escorts agency providing incall & outcall service for exciting price.
Kolkata Escorts
by Kolkata Escorts on Thursday, Sep 08 2016 19:11:35 +00:00
Mybabes Kolkata Escorts Agency offers attractive & high class professional Kolkata escorts service to seeking persons in Kolkata and all over in India. Kolkata escorts can visit you at your preferred hotel and join you at your own location or event.
High Profile Gurgaon Escorts
by High Profile Gurgaon Escorts on Monday, Sep 12 2016 09:02:27 +00:00
Nice and impressive post and i wanna say thanks for share this with us. I am so delighted to be here and to read this perfect post. Thanks for share this with us.
fb login
by fb login on Tuesday, Sep 13 2016 07:37:15 +00:00
Thank you very much for your post, it makes us have more and more discs in our life, So kind for you.I also hope you will make more and more excellent post and let’s more and more talk, thank you very much, dear.
Delhi Escort
by Delhi Escort on Tuesday, Sep 13 2016 11:37:18 +00:00
I am very happy that you have written such a good blog. I like it and i am going to bookmark it. Thanks
Aaditi Sharma
by Aaditi Sharma on Wednesday, Sep 14 2016 08:35:26 +00:00
I like this post. I have got such a good information from here. I am going to bookmark this blog this is very informative. Thanks Delhi Escorts
Ayushi Kapoor
by Ayushi Kapoor on Wednesday, Sep 14 2016 09:44:25 +00:00
My Name is Ayushi Kapoor and I am the one among the glamorous Delhi Independent Girl. Delhi Escort
by priyankasinghania on Saturday, Sep 17 2016 07:09:53 +00:00
Lovely blog post i am going to bookmark this blog post. Very good i like this. Thanks Female Escorts In Delhi
Gurgaon Escorts Agency
by Gurgaon Escorts Agency on Saturday, Sep 17 2016 21:40:02 +00:00
Gurgaon Escorts
by Gurgaon Escorts on Saturday, Sep 17 2016 21:40:51 +00:00
Escorts Services in Manali
by Escorts Services in Manali on Monday, Oct 17 2016 07:43:16 +00:00
Excellent job on the rest of the site. Beautifully designed and well written
Call Girls in Delhi
by Call Girls in Delhi on Tuesday, Oct 25 2016 09:58:48 +00:00
Amazing post the content was so nice and main thing is that it is very useful information for us it may help me in my future plans thanks to you for making this post keep going I appreciate your hard work
by zapya on Tuesday, Oct 25 2016 11:25:30 +00:00
Download Zapya for PC to share files and folders easily from PC to other devices