Publishing an ASP.NET 5 Application to IIS

I’ve recently been through the process of deploying an ASP.NET 5 site to IIS. While there is documentation for this process, I found that it still wasn’t as straightforward to follow as what I would have liked. This step by step guide with screenshots is the simplest method I’ve found to get it working on my local Windows 8.1 development machine.

The official guide from Microsoft was the most useful reference I found in getting this set up.

Visual Studio Tooling

There are a bunch of dependencies that we need to before we can get started. Let’s install these first.

Firstly, make sure that you have the latest version of the Microsoft ASP.NET and Web Tools installed. Mine was out of date initially, so I actually had to update this in order to get the project to compile.

Http Handler

ASP.NET 5 uses a different handler which is not installed by default. ASP.NET 5 RC1 (the latest version at the time of writing) requires version 1.2 or higher.

This can be downloaded at the following locations:

64 bit HTTP Platform Handler

32 bit HTTP Platform Handler

You can check that this has been successfully installed via Programs and Features

Runtime

Ensure that you’ve got the latest version of the run-time available using the following command:

dnvm upgrade

Publishing the Project

After you’ve created the new project in Visual Studio 2015 or your text editor of choice, open the command prompt and move into the project directory. You’ll then run the publish command from the directory one level above wwwroot.

Project Directory

dnu publish . --out "C:\publish\" --configuration Release --runtime dnx-clr-win-x64.1.0.0-rc1-update1

This should generate the following directory structure under C:\publish:

Copy the contents of this directory to the IIS directory:

cd C:\ 
xcopy C:\publish C:\inetpub\wwwroot\webapplication7 /s /e

Create a new website in IIS:

Modify the app pool so that it runs with No Managed Code set as the .NET CLR Version

Navigate to the website. If everything has worked correctly you should see the website. In our case we published a Web API endpoint so we see the following default values returned:

Related


Originally published at sean-hunter.io on December 4, 2015.