Deploy ASP.NET MVC Dependencies to Hosting Provider

Lately I’ve been working with Visual Studio 2010 and have been quite impressed by some of it’s features.   One feature in particular is the web site publishing capabilities.  The other day I was trying to frantically get a school project done and needed to deploy to my hosting provider, WinHost.  I have to briefly say that I’ve worked with a few top name providers that host ASP.NET and this one has been the best with great how-to’s on up-to-date technologies like Visual Studio Web Deploy and has a awesome management console.  Anyway, that’s not what I came to write about.  So after I deploy my code with a snap using Web Deploy, I get a few errors when trying to run my site.  Here I was all stoked that the Web Deploy was so effortless, to come to message like “Could not load file or assembly System.Web.WebPages.Razor” and “Could not load file or assembly System.Web.Helpers”.  Man what a buzz kill.  So not all hosting providers have ASP.NET MVC 3 yet (i.e. loaded in the GAC on there servers) which obviously we can’t do.  There are a couple of ways to fix this.  One is to grab the dlls listed below and store them in some library folder from which you can reference in your project.  The alternative, and better approach, is to indicate that your references you already have should be set to “Copy local”.  I’ve provided a screen shot and a list off the dlls which are needed by a ASP.NET MVC 3 application.  If you’re doing a MVC 2 or you will not need all these dlls.

image

DLLs needed:

  • Microsoft.Web.Infrastructure
  • System.Web.Abstractions
  • System.Web.Helpers
  • System.Web.Mvc
  • System.Web.Razor
  • System.Web.Routing
  • System.Web.WebPages
  • System.Web.WebPages.Razor

You may be wondering why your project doesn’t have all these references.  No sweat.  You can just add them.  I like to install Visual Studio Productivity Power Tools, it makes the add reference experience nicer.  Once you have the DLLs referenced in you project, right click the ones listed above and select Properties.  Set the “Copy local” attribute to true, see image below.  That’s it, redeploy your site and you’re set!

image

2 comments:

shiv said...

This is very extra ordinary web related blog.The postings in this blog are quite interesting and unique. thank you web hosting provider

Unknown said...

Hi,

This is very wanderfull blog! Its a way through which we can create dedicated application which is most beneficial for hosting as well as other web service application.I really used this service.....