How To Host ASP.NET MVC Web Application on Local IIS

In my previous articles we have learned how to create an ASP.NET MVC application and how to publish an ASP.NET MVC application. Now in this article we will learn how to host an ASP.NET MVC application on IIS . Hosting is required to make any application accessible to the end-user publicly on the web. So, in this article, we will learn how to host ASP.NET MVC application in IIS 10. The following steps are required to host any application.
If you don't know how to create, develop and publish  an ASP.NET MVC application then please refer to following step by step tutorial.
I hope you have learned required steps that is developing and publishing ASP.NET MVC application, Now lets start hosting MVC application on IIS.

Move the published code on Hosting Server

Copy the "Published files" which we have seen in our previous article Publishing an ASP.NET MVC Application Using File System and paste those on respective servers where you want to host the ASP.NET MVC application. In our last article we have published code in the E drive of my server, as shown in the following image .



Open IIS Manager

Now, open the IIS Manager from Windows menu or in any other ways you have known.

 

The above image is of IIS 10 Manager of my Windows 10 machine. The view as well as options might be different on your machine depending on the OS version.

Add Website to host an ASP.NET MVC application

Right click on "Site" in IIS and click on add new website, as shown in the following screenshot.


After clicking on "Add Website" option, it displays the following configuration window.


I hope you understood the preceding configuration by highlighted text.

Define Site Name & Application Pool

Define the site name which will be useful to uniquely identify the site within the IIS server. After specifying the site name, choose the application pool from available pools. You can even create a custom application pool with any desired name. Currently, our IIS manager has the following application Pools.

 

Choose the application pool depending on your application configuration. In this article, we are going to choose DefaultAppPool.

Browse and select Published Folder path

Now, choose the physical location of published code files by clicking on "Browse" button, as shown in the following image.


Now, click on "OK" button.

Define IP address & Port

Choose one IP address from the list of available IP addresses and define the unique port number for the application, which will be unique within the defined IP address.

Choose Protocol & Host name (optional )

Choose the protocol for your application i.e HTTP or HTTPS which requires port 443 to be open and choose the Host name which will be used publicly to access the application. After defining all the configurations, the web site configuration window will look like this.


Now, click on OK button. It will create and add the application in IIS.

Browse the application using web browser

Browse the hosted application using your system (PC/Laptop) browser , Click on browse hyperlink which is highlighted in the following image

 

After clicking on preceding IIS shown image browse hyperlink, then application will open in your default web browser as shown in the following image
 
 

Preceding is our IIS hosted ASP.NET MVC application which is running in browser.

Note
  • This article is just guideline to show how to host ASP.NET MVC web API application on IIS .
  • Optimize the speed by setting debug as false etc., from web.config file as per your skills.
  • In this article, the optimization is not covered in depth.
  • Configure the authentication in IIS as per your requirement . 

Summary

I hope, this article is useful for all the readers to learn about hosting an  ASP.NET MVC web application on local IIS. If you have any suggestions, please contact me.

Learn How to Create an ASP.NET MVC Application Step by Step

Post a Comment

www.CodeNirvana.in

Protected by Copyscape
Copyright © Compilemode