Hosting ASPNET Core application in IIS

Posted by Anuraj on Saturday, March 12, 2016

ASPNET Core IIS ASPNET 5 HttpPlatformHandler Kestrel

This post is about hosting an ASPNET 5 application in IIS. By default ASPNET5 comes with Kestrel web server. You need to do following steps to host an ASPNET5 app in IIS.

  • Compile and publish your application using dnu command like this.
dnu publish --runtime active

This command will publish your application with active runtime, in my scenario, which “1.0.0-rc1-update1” CLR version and x64 platform. You can get the details of installed runtimes and active one using “dnvm list” command. The compiled output available in the bin folder inside your application directory.

  • Create an application pool in IIS, with .NET CLR Version as no managed code option selected. Like this.

Create an application pool in IIS, with .NET CLR Version as no managed code option selected

  • Now create an application, make sure you’re selecting the application pool created in previous step.

Create an application IIS, with the created app pool

  • Physical Path of the application should point to the wwwroot of your published application.
  • Make sure you’re IISPlatform handler installed, else you can download it from here
  • You’re completed the configuration settings, you can browse your application.

If you’re using RC1 update1 like me, you may get a 404 instead of the default page. This is due to an defect with IIS Platform handler, you can resolve this by modifying code in the startup.cs, like this.

public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
    app.Map("/App1", (app1) =>
    {
        loggerFactory.AddConsole();
        app1.UseIISPlatformHandler();
        app1.UseDeveloperExceptionPage();
        app1.UseMvcWithDefaultRoute();
    });
}

This code will help to map you’re application url to ASPNET5 application.

Happy Coding :)



Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon



MVP
Subscribe


Copyright © 2017 - Anuraj P. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Hosted with ❤ by GitHub