Back to all posts

Deploying ASP.NET MVC 3 Applications to Production

Posted on Mar 13, 2011

Posted in category:
Development
ASP.NET

For those of you that follow me on Twitter you might already know that recently I've been starting to dive into ASP.NET MVC quite heavily and there was a lot of demand for blog posts on the topic. Therefore this will be the first of what will most likely become many blog posts on ASP.NET MVC. I have created a new category for these posts so that you can easily see, or avoid these as desired. This blog post is about the process of deploying a web application developed with ASP.NET MVC 3 to a production server that does not have ASP.NET MVC 3 installed.

Background

I recently completed my first ASP.NET MVC application that I wanted to deploy to production. My production webserver is running .NET 4 but I have not done any installation of ASP.NET MVC and at this time I'm not necessarily wanting to get that done yet. Now, by default on your development machines, all of the ASP.NET MVC DLL's are loaded from the GAC and therefore not copied locally, so a simple "Publish" failed miserably.

The Needed Files

THe application I was deploying was a simple "MVC 3 Web Application" created by the Visual Studio template, this is the situation that I am outlining below. It is possible that if you use additional items such as WebMatrix that you might need to deploy additional files. The remainder of this post assumes that you have installed items to their default locations. My following examples will show you the file paths based on development from a 64-bit machine if on a 32-bit machine you will need to remove the (x 86) portion from the directories.

First, you have "C:\Program Files (x 86)\Microsoft ASP.NET\ASP.NETWeb Pages\V1.0\Assemblies" folder. In there are a number of files needed for the run time to succeed, the following files from this directory were needed in my bin folder.

  • Microsoft.Web.Infrastructure
  • NuGet.Core.dll
  • System.Web.Helpers.dll
  • System.Web.Razor.dll
  • System.Web.WebPages.Administration.dll
  • System.Web.WebPages.Deployment.dll
  • System.Web.WebPages.dll
  • System.Web.WebPages.Razor.dll

The second installation directory is "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\assemblies". In this directory, there is only one file that you need to copy, System.Web.Mvc.dll.

Once I had all of these files copied my application started just like it was expected.

Conclusion

For those working in shared hosting environments or other environments where installing ASP.NET MVC 3 isn't an option on the production machines, this is a very quick and easy way to be able to get your application working in production. Post any comments/questions below.