Publish an ASP.NET Core app to IIS

This tutorial shows how to host an ASP.NET Core app on an IIS server.

This tutorial covers the following subjects:

Prerequisites

IIS configuration and website security involve concepts that aren't covered by this tutorial. Consult the IIS guidance in the Microsoft IIS documentation and the ASP.NET Core article on hosting with IIS before hosting production apps on IIS.

Important scenarios for IIS hosting not covered by this tutorial include:

Install the .NET Core Hosting Bundle

Install the .NET Core Hosting Bundle on the IIS server. The bundle installs the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module. The module allows ASP.NET Core apps to run behind IIS.

Download the installer using the following link:

  1. Run the installer on the IIS server.
  2. Restart the server or execute net stop was /y followed by net start w3svc in a command shell.

Create the IIS site

  1. On the IIS server, create a folder to contain the app's published folders and files. In a following step, the folder's path is provided to IIS as the physical path to the app. For more information on an app's deployment folder and file layout, see ASP.NET Core directory structure.
  2. In IIS Manager, open the server's node in the Connections panel. Right-click the Sites folder. Select Add Website from the contextual menu.
  3. Provide a Site name and set the Physical path to the app's deployment folder that you created. Provide the Binding configuration and create the website by selecting OK.

Warning Top-level wildcard bindings ( http://*:80/ and http://+:80 ) should not be used. Top-level wildcard bindings can open up your app to security vulnerabilities. This applies to both strong and weak wildcards. Use explicit host names rather than wildcards. Subdomain wildcard binding (for example, *.mysub.com ) doesn't have this security risk if you control the entire parent domain (as opposed to *.com , which is vulnerable). See RFC 9110: HTTP Semantics (Section 7.2. Host and :authority) for more information.

Create an ASP.NET Core Razor Pages app

Follow the Get started with ASP.NET Core tutorial to create a Razor Pages app.

Publish and deploy the app

Publish an app means to produce a compiled app that can be hosted by a server. Deploy an app means to move the published app to a hosting system. The publish step is handled by the .NET Core SDK, while the deployment step can be handled by a variety of approaches. This tutorial adopts the folder deployment approach, where:

  1. Right-click on the project in Solution Explorer and select Publish.
  2. In the Pick a publish target dialog, select the Folder publish option.
  3. Set the Folder or File Share path.
  4. Select the Publish button.
dotnet publish --configuration Release 
  1. Right-click on the project in Solution and select Publish >Publish to Folder.
  2. Set the Choose a folder path.
  3. Select the Publish button.

Browse the website

The app is accessible in a browser after it receives the first request. Make a request to the app at the endpoint binding that you established in IIS Manager for the site.

Next steps

In this tutorial, you learned how to:

To learn more about hosting ASP.NET Core apps on IIS, see the IIS Overview article:

Additional resources

Articles in the ASP.NET Core documentation set

Articles pertaining to ASP.NET Core app deployment

Articles on IIS HTTPS configuration

Articles on IIS and Windows Server

Deployment resources for IIS administrators

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.