Sorted By: Month (9) and Year (2015)

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())
    {
        app.UseErrorPage();
    }
    else
    {
        // Add Error handling middleware which catches all application specific errors and
        // send the request to the following path or controller action.
        app.UseErrorHandler("/Home/Error");
    }

    // ...

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:

image

image

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

image

image

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.

Speaking at Web European Conference 2015 in Milan

Web European Conference 2015 will happen in Milan on the 26th of September and I will be talking about ASP.NET 5 there!
2015-09-12 12:14
Tugberk Ugurlu


I am really excited that I will be speaking at Web European Conference 2015 in Milan on the 26th of September.

web-euro-conf

If you haven't heard of Web European Conference before, here is the description I am copying from the official web site:

The first European Conference dedicated to the future of Development on all technologies. Everything about the newest and coolest framework for building modern web applications and websites: ASP.NET vNext, node.js, ruby, angular.js and much more.

You can view the conference schedule here. Just look at the details of the conference and ask this question: how more awesome can a conference be? It's all about Web, it's in Milan and the keynote speaker is Scott Hanselman :)

I will give a talk on getting into the bowels of ASP.NET 5. It should be fun. For the talk, I will assume that you have a prior knowledge on ASP.NET 5, and know how it’s different from its previous versions. If you want to benefit from this session and haven't got the chance to get up to speed wıth ASP.NET 5 yet, here are a few links to help you:

Looking at web site now and it seems like you still have a chance to register. I hope to see you there :)

Tags