How to Configure, Install and Deploy ASP.NET Core to IIS

How to Configure, Install and Deploy ASP.NET Core to IIS

ASP.NET Core is a free and a composable framework for building web apps. It is open source and completely free. You can get it on Github. The modular framework performs significantly better than ASP.NET. In this article, you will find the complete guide for configuring, installing and deploying it to IIS.

Configuring Your ASP.NET Core App for IIS

When you create a new ASP.NET Core, you will see a Program.cs file, which has the following codes:

publicclassProgram
{
    publicstaticvoidMain(string[] args)
    {
        var host = new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup()
            .Build();

        host.Run();
    }
}

Here, WebHostBuilderis configuring and creating WebHost, which is basically an object that functions as the application and the web server. UseKestrel() is registering the IServer interface for Kestrel, which is a cross-platform web server. Here, IServer will work as a host for your app. By including UseIISIntegration(), you are using IIS as a reverse proxy in front of Kestrel.

Creating an ASP.NET Core project also results in the creation of a web.config file. It looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".logsstdout" forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>

Basically, it registers AspNetCoreModule, which deals with all the incoming traffic to IIS, as an HTTP handler. It also works as a reverse proxy server. But more importantly, AspNetCoreModule is responsible for running your web app successfully.

Installing .NET Core Windows Server Hosting Bundle

You can download .NET Core Windows Server from here. You need to install it before deploying your web app. At the same time, .NET Core runtime, libraries and ASP.NET Core module will also be installed. Then you might have to run the following command in the command prompt:

net stop was /y

It will stop the IIS Admin Service and all other relevant services. Now, run this command:

net start w3svc

It will force the IIS services to re-read the registry. As a result, all the changes will be picked up for the extensible web server.

Deploying ASP.NET Core to IIS

Step 1: Pick a Publish Target

Step 2: Copy Your Publish Output to Your Preferred Location

Now, you have to copy the files to your desired location. In our case, we are copying them right here:

C:inetpubwwwrootAspNetCore46

If you are deploying to a local dev box, you have the option of copying the files locally. But in case of the remote server, you should compress them and then move to the server.

Step 3: Create a New Application Pool in IIS

Create a new IIS application pool under the .NET CLR version of “No Managed Code.” Then create your new IIS app under your current IIS site. You can also create a new IIS site. Then point it to the folder that contains the files of your publish output.

Step 4: Load your application

In this step, your application should work perfectly. But if it doesn’t happen, open your web.config file and specify the process for IIS initiating ASP.NET Core. Also, activate out logging by setting stdoutLogEnabled to true. It will allow you to the logs, identify the issue and create a solution.

Conclusion

In this article, you have learnt the detailed way for configuring, installing and deploying ASP.NET Core to IIS. By using the extensible web server to the ASP.NET Core hosting, you can enjoy an extra level of configurability and security.

Check out these top 3 WordPress hosting services:

A2 Hosting
$1.95 /mo
Starting price
Visit A2 Hosting
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.8
  • Pricing
    4.0
IONOS
$1.00 /mo
Starting price
Visit IONOS
Rating based on expert review
  • User Friendly
    4.5
  • Support
    4.0
  • Features
    4.5
  • Reliability
    4.5
  • Pricing
    4.3
Webdock
$0.95 /mo
Starting price
Visit Webdock
Rating based on expert review
  • User Friendly
    3.8
  • Support
    4.5
  • Features
    4.5
  • Reliability
    4.3
  • Pricing
    4.3

How to View the Number of Active User Sessions on Your IIS Website

This article will discuss a way of viewing the number of active user sessions us
less than a minute
Md. Ehsanul Haque Kanan
Md. Ehsanul Haque Kanan
Hosting Expert

How To Create A Site Navigation Hierarchy With ASP.NET

As your site grows, and as you move pages around in the site, it can become diff
less than a minute
Max Ostryzhko
Max Ostryzhko
Senior Web Developer, HostAdvice CTO

How to Install the WISA (Windows, IIS, SQL, ASP.NET) Stack

WISA is an acronym which stands for (Windows, IIS, SQL, and ASP.net).WISA uses W
less than a minute
Vladimir Rakov
Vladimir Rakov
Hosting Expert

How to Set Up IIS Application Pool (Windows) in Plesk

IIS Application Pool contains all web applications installed on your sites. You
less than a minute
Elizabeth Njoroge
Elizabeth Njoroge
Author
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top