A Step-by-Step Guide to Deploying Your ASP.NET Project in IIS

Binari Dissanayake
4 min read7 hours ago
Designed by author

First of all, let’s find out what ASP .NET and IIS mean. ASP .NET is a cross-platform open-source web framework created by Microsoft to build modern web apps and services based on .NET.

Internet Information Service (IIS) is a flexible, manageable web server from Microsoft that runs on the Windows system to serve requested HTML pages or files. IIS supports a wide range of protocols, including HTTP, HTTPS, FTP, and more. It’s highly configurable and can be used to host ASP.NET applications, providing essential features such as request handling, security, logging, and performance monitoring.

Deploying your ASP.NET project in IIS is a critical step in bringing your application from the development environment to production. IIS ensures that your application is accessible to users, provides robust security features, and offers extensive logging and monitoring capabilities

In this guide, I will walk you through the process of deploying an ASP.NET project in IIS. I will cover everything from preparing your project for deployment, installing and configuring IIS, deploying the project, configuring necessary settings, and testing the deployment. By following these steps, you’ll be able to successfully deploy your ASP.NET application and ensure it’s ready for production use.

Step 1: Prepare your ASP .NET application.

  • Build the project in Visual Studio
  • Publish your project.
  • Right-click on Solution Explore, and choose Publish.
  • In the publish dialog, select “Folder” as the publish target.
  • Specify a folder path where the published files will be stored on your local machine. This is typically a temporary folder where files will be compiled and prepared for deployment.
  • Now our application build is successful. You can see the files in your target folder.

Step 2: Install IIS

  • First, ensure IIS is installed on your server. If not, click the following link to install IIS.

https://learn.microsoft.com/en-us/iis/application-frameworks/scenario-build-an-aspnet-website-on-iis/configuring-step-1-install-iis-and-asp-net-modules

Step 3: Deploying the Project to IIS

Copy files to the server:

  • Open a File Explorer window on your local machine where the published files are located.
  • Select all files and folders that were published (usually everything inside the published folder).

Create a new folder on the server:

  • Connect to your server where IIS is installed using Remote Desktop or another remote access method.
  • Navigate to C:\inetpub\wwwroot on your server.
  • Right-click within the wwwroot directory.
  • Choose “New” -> “Folder” from the context menu.
  • Name the new folder with your website name (e.g., MyAspNetApp).

Paste Published Files:

  • Double-click to open the newly created folder (MyAspNetApp) within C:\inetpub\wwwroot.
  • Paste the copied files and folders from your local machine into this directory on the server.

Verify File Transfer:

  • Ensure that all files and folders from your ASP.NET project have been successfully copied to C:\inetpub\wwwroot\MyAspNetApp on your server.

Step 4: Configure IIS

  • Next, search for the IIS manager in the control panel. Then you will get an interface as follows. (Ensure you have administrator permission on the server.)
  • Then right-click on the server name and click on add website.
  • Provide the name of the website along with the physical path where the application build was placed for your application (C:\inetpub\wwwroot\MyAspNetApp).
  • Give the website host name also.

Step 4: Editing the Hosts File to Map IP Address to Hostname

  • Open the C Drive and find the system 32 Folder. Open the Driver Folder and after that, open the etc. folder and then open the Host File. (C:\Windows\System32\drivers\etc)
  • Open the host file using Notepad

Edit the Hosts File:

  • At the bottom of the hosts file, add a new line with the IP address and the hostname you want to map. For example:
    192.168.1.100 idenitymanagement.com
  • Replace 192.168.1.100 with the IP address of your server and idenitymanagement.com with the desired hostname for your ASP.NET application.

Now Go to IIS Manager and Browse your website. Right-click -> Manage Website -> Browse

Now the application is live in IIS.

References

https://learn.microsoft.com/en-us/iis/application-frameworks/scenario-build-an-aspnet-website-on-iis/configuring-step-1-install-iis-and-asp-net-modules

https://www.c-sharpcorner.com/article/deploying-asp-net-mvc-application-on-iis-server/

--

--