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 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.
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.
Publish ASP.NET Core app to a local folder using Visual Studio
Right-click on the project in Solution Explorer and select Publish.
In the Pick a publish target dialog, select the Folder Publish option.
Set the Folder or File Share path.
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.
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.
Publish ASP.NET Core app to a local folder using .NET Core CLI
In a command shell, publish the app in Release configuration with the dotnet publish command: dotnet publish --configuration Release
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.
Publish ASP.NET Core app to a local folder using Visual Studio for Mac
Right-click on the project in Solution and select Publish > Publish to Folder.
Set the Choose a folder path.
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.
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.
Create an IIS site in IIS Manager.
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.
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.
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