Host ASP NET Core in IIS

Kailash Chandra Behera | Wednesday, August 19, 2020

Introduction

This blog provides the complete guidelines on how to host ASP NET Core in IIS, hosting ASP.NET Core is as easy as like ASP.NET MVC application but has little difference. Here will discuss the steps to host ASP NET Core on Windows with IIS using Visual Studio, .Net core CLI and from Mac.

host asp net core on windows with iis

Host ASP NET Core in IIS

Getting Started

The below steps are helping to host ASP NET Core in IIS, Three different steps are given to publish into a local folder, the steps are applicable for the different developer who uses Microsoft Visual Studio or .NET Core CLI or Microsoft Visual Studio in Mac. follow the appropriate steps which are applicable to you to publish the ASP.NET Core into a local folder.

  1. Install the ASP.NET Core Hosting Bundle:- The .NET Core Hosting Bundle installs the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module on the hosting system. The ASP.NET Core Module allows ASP.NET Core apps to run behind IIS. Click on the link to navigate my previous blog, which guides how to install it.

  2. Publish ASP.NET Core app to a local folder using Visual Studio

    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.

      1. If you created a folder for the IIS site that's available on the development machine as a network share, provide the path to the share. The current user must have write access to publish to the share.

      2. If you're unable to deploy directly to the IIS site folder on the IIS server, publish to a folder on removable media and physically move the published app to the site folder on the server, which is the site's Physical path in IIS Manager. Move the contents of the bin/Release/{TARGET FRAMEWORK}/publish folder to the IIS site folder on the server, which is the site's Physical path in IIS Manager.

  3. Publish ASP.NET Core app to a local folder using .NET Core CLI

    1. In a command shell, publish the app in Release configuration with the dotnet publish command: dotnet publish --configuration Release

    2. Move the contents of the bin/Release/{TARGET FRAMEWORK}/publish folder to the IIS site folder on the server, which is the site's Physical path in IIS Manager.

  4. Publish ASP.NET Core app to a local folder using Visual Studio for Mac

    1. Right-click on the project in Solution and select Publish > Publish to Folder.

    2. Set the Choose a folder path.

      1. If you created a folder for the IIS site that's available on the development machine as a network share, provide the path to the share. The current user must have write access to publish to the share.

      2. If you're unable to deploy directly to the IIS site folder on the IIS server, publish to a folder on removable media and physically move the published app to the IIS site folder on the server, which is the site's Physical path in IIS Manager. Move the contents of the bin/Release/{TARGET FRAMEWORK}/publish folder to the IIS site folder on the server, which is the site's Physical path in IIS Manager.

  5. Create an IIS site in IIS Manager.

    1. On the IIS server, create a folder to contain the app's published folders and files. In the following step, the folder's path is provided to IIS as the physical path to the app.

    2. Open the IIS Manager and in 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.

Summary

In the above, we discussed how to host asp net core on windows with iis by Visual Studio, .Net core CLI and from Mac. I hope you have enjoyed it a lot.Host ASP NET Core on Windows with IIS

Thanks