How to Host ASP.NET Core Web Application Into IIS Server


How to Host ASP.NET Core Web Application Into Local IIS Server

In this article, I will discuss How to Host ASP.NET Core Web Applications Into Local IIS Server. Please read our previous article discussing Bundling and Minification in ASP.NET Core Using WebOptimizer with Examples.

What is Hosting a Web Application?

Hosting a web application refers to the process of making your application available to users over the Internet. In more technical terms, it involves placing your application on a web server, which is a computer system specifically designed to store, process, and deliver web pages to users.

What is an IIS Server?

IIS (Internet Information Services) Server is a web server software created by Microsoft. It’s used to host websites and web applications and is a part of the Windows Server family of products. Key features and characteristics of IIS Server include:

  • Hosting Websites and Web Applications: IIS is primarily used to host websites, providing a platform for web applications developed in ASP.NET, PHP, and other technologies.
  • Support for Various Protocols: It supports HTTP, HTTPS, FTP, FTPS, SMTP, and NNTP protocols.
  • Security Features: IIS provides several built-in security features like authentication, authorization, and SSL support to ensure secure communication and protect sensitive data.
  • Extensibility and Customization: It can be extended and customized using various modules and handlers. This allows developers to add or enhance capabilities based on their specific needs.
  • Management and Administration Tools: IIS comes with management tools for configuring and administering web servers and sites. This includes IIS Manager, a graphical user interface, and command-line tools.
  • Application Pool: This feature allows for isolation between different web applications, improving security and stability. Each application pool can run with its own settings and under its own identity.
  • Performance Features: IIS includes features for improving performance, such as caching, compression, and load balancing.
  • Integration with Microsoft Technologies: It is tightly integrated with other Microsoft technologies and services like Windows Server, Active Directory, and SQL Server.
How to Host ASP.NET Core Web APP Into IIS Server

Hosting an ASP.NET Core web app on a local IIS server involves several steps. Let us proceed and understand these steps in detail:

Install IIS

First, ensure that Internet Information Services (IIS) is installed on your machine.

On Windows 10/11: Go to Control Panel > Programs > Programs and Features > Turn Windows features on or off. Check Internet Information Services and click OK as shown in the below image:

How to Hots ASP.NET Core Web APP into IIS Server

Install .NET Core Hosting Bundle

Download and install the .NET Core Hosting Bundle. It includes the .NET Runtime, .NET Library, and ASP.NET Core Module. This module is necessary for hosting ASP.NET Core applications. To install the .NET Core Hosting Bundle, please visit the following website, and based on the .NET Core Application version, please install the required .NET Core runtime. I will install the .NET Core 6 Hosting Bundle as I have developed an application using .NET 6.

Once you visit the above URL, it will open the following page. Please download the Hosting Bundle from this page, as shown in the image below. Installing the Hosting Bundle, which includes the .NET Runtime and IIS support, is recommended on Windows.

Install .NET Core Hosting Bundle


Once you download the .NET Core Hosting Bundle, please install it on your machine.

Note: ASP.NET Core Hosting Bundle contains everything you need to run existing web/ server apps. The bundle includes the .NET runtime and the ASP.NET Core runtime, and if installed on a machine with IIS, it will also add the ASP.NET Core IIS Module. If you only want the .NET or ASP.NET Core runtime, you’ll find them in .NET 6.0 Downloads.

Create ASP.NET Core Application

Let us create a new ASP.NET Core Application using the Model View Controller Project template and using .NET 6. We are giving the application name as CoreWebApp. The project will be created with the following folder structure:

Create ASP.NET Core Application

Now, we need to deploy the above application into IIS.

Publish Your ASP.NET Core Application

We need to publish the application to deploy the ASP.NET Core Application into IIS. So, first, create a folder in your machine where you need to store the published code of your application. I am going to create a folder called CoreAppPublished within the D drive of my machine:

To publish the application, in Visual Studio, right-click on your project and select the Publish option from the context menu, which will open the following window. Here, you need to choose how you want to publish your application. From this window, please select the Folder option and then click on the Next button as shown in the below image:

Publish Your ASP.NET Core Application


When publishing an ASP.NET Core application, you have multiple options for deployment targets, each serving different purposes and scenarios. Here’s a brief overview of the options you mentioned:

  • Azure: Azure is Microsoft’s cloud computing platform, offering services such as Azure App Service for hosting web applications. Publishing to Azure means your ASP.NET Core application will be hosted in the cloud, benefiting from Azure’s scalability, security, and integration with other Azure services.
  • Folder: Publishing to a folder creates a set of files that can be hosted on any server with the appropriate .NET runtime installed. This is a flexible option because you can manually copy these files to a server, create a package for distribution, or use them as part of a larger deployment process.
  • FTP/FTPS Server: File Transfer Protocol (FTP) or FTP Secure (FTPS) is a standard network protocol used for the transfer of computer files between a client and server on a computer network. Publishing to an FTP/FTPS server involves transferring your application files to a remote server. This is a common choice for shared hosting environments or for servers where more direct, file-level control is required.
  • Web Server: This option implies deploying your application directly to a web server, such as IIS, Apache, or Nginx. This typically involves more manual steps, including setting up the server environment, configuring the web server, and deploying the application files directly.
  • Import Profile: Import Profile allows you to import publish settings from a profile file. This is useful if you have predefined settings or if you’re migrating settings from one environment to another. Publish profiles can include all the necessary settings for deploying to a specific target.
  • Docker Container Registry: Docker is a platform for developing, shipping, and running applications in containers. Publishing to a Docker container registry involves packaging your ASP.NET Core application into a Docker container and pushing it to a container registry like Docker Hub or Azure Container Registry. This approach is beneficial for ensuring consistency across environments, as the container includes both your application and its dependencies.

Once you click on the Next button, it will open the following window. Here, you need to select the Folder where you want to publish the application files. We have created a folder called CoreAppPublished in the D drive, so select that folder and then click on the Finished button as shown in the below image:

Publish Your ASP.NET Core Application

Once you click on the Finish button, it will open the following Ready to Publish window. From this window, you need to click on the Publish button as shown in the below image:

Publish Your ASP.NET Core Application

Once you click on the Publish button, it will take some time to publish the application file, and after successful publishing, you will get the following message:

Publish Your ASP.NET Core Application

Now, if you verify the D:\CoreAppPublished folder, you should see the following folder and files:

Publish Your ASP.NET Core Application

Create Site in IIS:

Open IIS Manager. Right-click on Sites in the Connections pane and select Add Website. Provide a Site name. For the Physical path, browse to the folder where you published your application. Assign a Port number (e.g., 8080 to avoid conflicts with default websites). Click OK to create the site as shown in the below image.


Create Site in IIS

This will also automatically create an application pool with the same name as your Site Name:

Configure Application Pool

In IIS Manager, go to Application Pools. Right-click on your new application pool (MyCoreMVCApp) and select Advanced Settings. Change the .NET CLR version to No Managed Code since ASP.NET Core runs in its own runtime, and then click on the OK button, as shown in the image below.

Configure Application Pool

Modify Permissions

Ensure the IIS_IUSRS group has access to the published application folder. Right-click on the folder > Properties > Security. Edit to add IIS_IUSRS if it’s not listed, and give it read and execute permissions.

Test the Application

Open a web browser and navigate to http://localhost:[PortNumber], where [PortNumber] is the port you assigned to your website in IIS. I have assigned the port number 8083, so I am visiting the URL http://localhost:8083/ as shown in the image below.

How to Hots ASP.NET Core Web Application into a Local IIS Server

  • If you encounter errors, check the Windows Event Logs and the application logs for details.
  • Ensure the ASP.NET Core Module is correctly installed.
  • Check that the application pool is configured to use No Managed Code.
Additional Considerations
  • For production environments, more configurations like SSL, logging, and others might be required.
  • Always test your application thoroughly in a local environment before moving to production.

In the next article, I will discuss How to Use SSL in a Local IIS Server While Hosting an ASP.NET Core Application. In this article, I try to explain How to Host ASP.NET Core Web Applications In a Local IIS Server. I hope you enjoy this article, How to Host ASP.NET Core Web Applications into Local IIS Server.


Leave a Reply

Your email address will not be published. Required fields are marked *