How to do it...

  1. Let's create a new ASP.NET Core project and serve it in IIS:
dotnet new web 
  1. Open the Program.cs file and look for the following code block:
public static IWebHost BuildWebHost(string[] args) => 
WebHost.CreateDefaultBuilder(args) 
.UseStartup<Startup>() 
.Build(); 
  1. We should add a UseIISIntegration() method call in that function as follows:
public static IWebHost BuildWebHost(string[] args) => 
WebHost.CreateDefaultBuilder(args) 
.UseStartup<Startup>() 
.UseIISIntegration() 
.Build(); 
The UseIISIntegration() method call is important and required if we're going to deploy our project to IIS.

UseIISIntegration() method makes the ASP.NET Core application to use IIS as a reverse-proxy and specify which port will be listened, and ...

Get ASP.NET Core MVC 2.0 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.