Publish Web Application To Local Server

I can still remember my beginning days of ASP.NET learning when I had no idea of IIS server and the concept of web site publishing. I was writing code in Visual Studio and running applications in the same environment. Though it was enough fun for beginners, one good day I started to develop a small application for our college and then the thought occurred to me, how can we release the application globally? How can everyone all people can able to access through network?

Then I started to search in net to learn publishing website to real web server. Truth to be told, the searching and finding solution was not smooth at that time, any way I have enjoyed the struggle.

So, to help those guys who are in that step currently, I am writing this article. Fine, we will learn to publish website in local IIS server from Visual Studio environment.

First thing first, Please check Whether IIS is install and running in your local server or not. To check it, type “localhost” into a browser.


If IIS is running then you will see the screen shown above. If you get it, cool proceed to the next step. Otherwise install IIS in your computer going to Control Panel and selecting "Programs" -> "Turn Window features on or off" and install IIS.

The next step is to create a brand new web application that we will publish on IIS. So, open Visual Studio and create one empty web application. Here I created one empty application.

empty Web Application

The solution is nearly empty and we just need to add a .aspx file that will contain the following code in the page_load() event.

protected void Page_Load(object sender, EventArgs e)

Right-click on the application and select the “publish” option as the following screen.


After clicking on the publish option you will see the following screen. It will ask you to create a profile. At this point I will say I am using Visual Studio 2013. If you are using a different version of Visual Studio then you may encounter a different screen.

publish option

Click one new profile and provide a profile name and click on OK.

new profile

After clicking on OK, it will take you to the “connection” option. Click on "Publish" and select "File System"; the reason is, we want to publish the application to the local server. If needed we can publish the application to a remote FTP or Azure platform.


Now after clicking, the following screen will appear. Here you need to choose the publish location of the application. In this example, I have chosen the directory within wwwroot of the initpub folder. You will find it within the “C” drive.

initpub folder

After clicking on "Next", it will show the following screen to ask you whether you would like to publish in debug mode or release mode.
debug mode or release mode

I have chosen release mode, because I want to publish it in release mode. After clicking on the "Next" button, you will encounter the following screen.
release mode

It's nothing but to show the preview. Now click on the "Publish" button to publish the application. If you are lucky enough , you will see the following screen. It's showing that the application was published to the local server.
published in local server

Now, open IIS Manager and refresh the site collection node or refresh “Default Web Site”. You will find the application that we published to IIS.
IIS manager

Then right-click on the application and click on "convert to application". Once we have clicked we get this:
convert to Application

It will be converted to an application and ready to serve HTTP requests. Now if we browse to the URL in the browser we will see the response from the application, as the following screen.
HTTP request

Cheers! We have successfully published our website to the local IIS server.