Deploy ASP.NET Core WebApp to a Local Network using IIS

In this tutorial, we will learn how to Deploy and Share ASP.NET Core WebApp to a Local Network using IIS on Windows. Deploying ASP.NET Core Web APP on IIS is an easy task once you understand and follow the correct steps to prepare your development and deployment environment.

What is IIS?

IIS stands for “Internet Information Services,” a web server provided by Microsoft to host the websites. Internet Information Services (IIS) is a flexible, general-purpose web server from Microsoft that runs on Windows systems to serve requested HTML pages or files.

The first and most important thing you need is to download and install the latest Visual Studio 2019. Visual Studio 2019 supports the newest version of Dot Net SDK, which is 5.0

Note that you cannot use Visual Studio 2017 to develop Dot Net Core 3 or Dot Net 5 apps.

I. Create a new ASP.NET Core Web Application

Let’s create a new ASP.NET Core Web Application for the deployment demo. If you already have a project to deploy, skip this part and move to the next step. If not, follow the steps below.

  • Select File > New > Project.
  • Select ASP.NET Core Web Application. Name the project DeployDemo to have the same namespace as my project. Click OK.
  • Select an ASP.NET Core Web Application. and then uncheck Configure for HTTPS.
  • Lastly, Click on Create.
ASP.NET 5.0

II. Enable IIS on Windows?

If you have already enabled IIS, then you can skip this step. But if not then enabled it by following the below steps:

You may also visit this article for detailed step to enable IIS on windows. link

  1. Open Control Panel and then click on the “Programs and Features.”
  2. Click on “Turn Windows features on or off.”
  3. Select Internet Information Services and click on the OK button.
  4. To see whether IIS is enabled, press the Windows + R key and type inetmgr, and click on OK.
  5. IIS Manager is open.
Enable IIS on Windows Manager
Enable IIS on WIndows
IIS Manager
IIS Manager

III. Install the ASP.NET Core Module/Hosting Bundle

ASP.NET Core offer two Deployment Mode, Framework-Dependent and Self-Contained.

Deployment Mode
Deployment ModeDifinition
Framework-DependentDependent on what framework is installed on the machine. (.net core 3.1 or .net core 5.0)
Self-Contained This deployment mode will produce an application that includes the .NET Core runtime and libraries.
  1. To download the latest .Net Core hosting bundle, you may use this link.
  2. Once you finish the download, install the bundle into your machine.
  3. Now, we are ready to configure IIS to run a .Net core application.
ASP.NET Core Hosting Bundle

IV. Create Application Pool and Website Application

To configure IIS for the deployment of ASP.NET Core Web Application. Just follow the steps below.

  1. Create a new Application Pool. Open IIS and select Application Pools.
Applciation Pool on IIS Management

2. Click on the Add Application Pool option from the Actions pane. See the screenshot below.

New Application Pool for asp.net core hosting bundle

3. Input desired name to your new application pool, then select No Manage Code under the .NET CLR version. Click “OK” to create the application pool.

No Managed Code

The newly created Application Pool will be added to the list of available pool. See the image below.

Add Application Pool

4. Now, we are ready to create a website in IIS. To create expand Sites option. Add a new application by right-clicking the default websites then choose Add Application

Add New Applciation

5. Provide a name and path for your web application. This website location is where you will place your website’s resources. In my case I use “C:\inetpub\wwwroot\deployDemo” . Click the “OK” button once done.

Deploy and Share ASP NET Core WebApp to a Local Network using IIS

Now, you should be able to see the Demo application under the default website.

Deploy and Share ASP NET Core WebApp to a Local Network using IIS

6. You can browse the website by right-clicking on the Demo Application then choose Manage Application » Browse. Obviously, this is still an empty website, so let’s deploy our ASP.NET Core on this Demo website’s path.

IIS Browse

IV. Deploy ASP.NET Core Web Application to IIS

Let’s configure and deploy our ASP.NET Core Web Application that we created from the very start of this tutorial. This how my ASP.NET Core project looks like.

Website sample Web App
  1. To publish a website go to Build » Publish DeployDemo. This will open the Publish window.
Publish menu

2. Choose Folder from the option. Click the Next button. See the screenshot below.

Choose Folder option

3. Then browse the path for your website location which in my case it’s “C:\inetpub\wwwroot\deployDemo“. Click on the Finish button to proceed. See the screenshot below.

Input website build location

4. Now, Deploy your application by pressing the Publish button. Wait for Visual Studio to deploy your app. See the screenshot below.

Publish ASP.NET Core WebApp

5. Now, open your website path you will find build files of your application. These are the files found in my website location.

Deploy and Share ASP NET Core WebApp to a Local Network using IIS

6. Let’s test if the deployment was successful. Open IIS Manager, then browse Demo Application. You should be able to open your application using any browser.

Deploy and Share ASP NET Core WebApp to a Local Network using IIS

This the website using localhost:8080 port from my IIS.

Deploy and Share ASP NET Core WebApp to a Local Network using IIS

V. Configure IIS Website to be Accessible from within your Network

To share your website with a network, we need to set IIS binding and use our local IP as an address(http://192.128.2.44:8080/Demo). To do that, follow the steps below.

  1. Select the Default Website from IIS then choose Bindings.
IIS Binding option - Deploy and Share ASP NET Core WebApp to a Local Network using IIS

2. Add new Binding and select your local IP address from the drop-down menu. Assign port, which, in my case, I use 8001. Click the “OK” to add the site binding. See the image below.

Add IIS Bindings - Deploy and Share ASP NET Core WebApp to a Local Network using IIS

3. Now, you should be able to access your website using this address “http://192.168.1.44:8001/Demo”. It may defer on the local IP address you have on your local machine.

Deploy and Share ASP NET Core WebApp to a Local Network using IIS

4. To access this address from a different machine on your local network. Open Windows Defender Firewall with Advanced Security. Let’s add inbound Rules for the port that we used on the Demo Application, port 8001. To do that, click New Rule, then choose the port. Click Next to proceed with the next step.

Deploy and Share ASP NET Core WebApp to a Local Network using IIS

5. Input the port 8001 then click the Next button. The port may differ on what you use on your IIS web Application. See the screenshot below.

Deploy and Share ASP.NET Core WebApp to a Local Network using IIS

6. Select Allow the Connection then click Next to proceed. See the screenshot below.

Deploy and Share ASP.NET Core WebApp to a Local Network using IIS

7. Leave the default settings as shown below then click Next to proceed.

Deploy and Share ASP.NET Core WebApp to a Local Network using IIS

8. Name the new Inbound Rule, which in my case, I named it “8001 Demo Deployment,” then click the Finish button.

Firewall Inbound Rule - Deploy and Share ASP.NET Core WebApp to a Local Network using IIS

Now, you should be able to access your website from anywhere within your network.

Summary

This tutorial taught us how easy it is to Deploy and Share ASP.NET Core WebApp to a Local Network using IIS on a Windows machine. We also configure the IIS website to be accessible from anywhere within your local network, which can work in a group and share Web API. Hopefully, you can use this tutorial to reference your future projects.

KEEP CODING!

Visit me on my facebook page @freecodespot.