Hosting ASP.NET MVC Web Application On Local Machine

Most of the steps to deploy a web form application and MVC application are equivalent, but in some cases the developers confused it a bit (You can see step 3 for this confusion). Hope this article gives a nice overview on it.

Prerequisite

In order to explain the steps, I assume you have an ASP.NET MVC application that is ready to build without any error.

Step 1: Publish your MVC application in a local file path using Publish option in Visual Studio.

 

For this example I have published my application in the following path: C:\MVCDemo.

 

Step 2: Create a Virtual directory in IIS and map the above published file path to it. 

 

If you have any doubts in creating virtual directory refer my blogs: Create virtual directory on IIS using Visual Studio and Create Virtual directory on IIS.

Step 3: You are almost done! The only thing pending is you need to browse the website just published. This is where most of the ASP.NET developers (especially who is a newbie to ASP.Net MVC will know that what they were doing: Expand the Virtual directory, go to Views, click Switch to content view and select the cshtml file, right click on it and click Browse that throws 404 error in the browser.

home content 

  

The above issue is common to all ASP.NET developers with ASP.NET WebForm background. In order to browse the MVC application, you need to mention the path in the form like “http://localhost/YourControllerName/YourActionMethod" that is the url routing pattern specified by default.



Conclusion

Hope this article will help those who are news to MVC and solve the issue while hosting his/her application on local machine. Happy coding!


Similar Articles