Wednesday, February 2, 2022

Deploy / Publish ASP.NET Core API application In IIS

Introduction

 
ASP.NET Core is a cross platform and open source framework which is used to build  modern web apps, API services and many more. In this article we are going to see how to deploy the ASP.NET Core API application in IIS.
 
Tooling
  • Visual Studio 2019
  • IIS
  • POSTMAN

Creating an application

 
Open Visual Studio 2019 -> Click on create new project from the start up screen.
 
Deploy ASP.NET Core API application In IIS 
 
Click on ASP.NET Core Web application template -> give the project name, in my case I named it as AspCoreHosting -> click on create.
 
Choose API template, as shown in below figure. 
 
Deploy ASP.NET Core API application In IIS 
 
Now run the application from visual studio and test the API in POSTMAN as shown in the below figure. 
 
Deploy ASP.NET Core API application In IIS
 

Deploy the application to IIS

 
Let’s create a package of the application, right click on the project and select publish, as shown in the below figure.
 
Deploy ASP.NET Core API application In IIS 
 
Choose IIS, FTP, etc option from publish target list and choose the publish method as file system, and click on save.
 
Deploy ASP.NET Core API application In IIS 
 
Deploy ASP.NET Core API application In IIS 
 
Open IIS, right click on application pools -> Add app pool -> Choose the .NET CLR Version as No Manager Code and name the app pool. in my case I named it as .NET Core V2.2 with pipeline mode as Integrated.
 
Deploy ASP.NET Core API application In IIS
 
Note
Creating a new application pool for .NET Core is optional
 
Right click on sites -> Add site ->Give the Site name -> select the Application pool as .NET Core V2.2 -> choose the package path -> and give a port number as shown in the below figure.
 
Deploy ASP.NET Core API application In IIS 
 
Run the web site
 
Deploy ASP.NET Core API application In IIS
 
Oops we got a configuration error. The problem is, to run the .NET Core application in IIS we need to install “dot net core windows hosting bundle”. Just download and install it using the below link.
 
Deploy ASP.NET Core API application In IIS
 
Once it is installed, test the API using POSTMAN tool
 
Deploy ASP.NET Core API application In IIS
 
Yes, now the application is up and running in IIS
 

Summary

 
We have seen how to deploy the ASP.NET Core API application in IIS by installing the dot net core windows hosting bundle 

Note : Make sure the machine is installed with the ASP.Net core Runtimes and Asp.netcore windows hosting bundle

    2 comments:

    Blaine Foster said...

    Lovved reading this thank you

    Troy Sosa said...

    Great reading your blog ppost

    Popular Posts