5

I've set up IIS 7 on my Windows 2008 R2 server according to this guide and deployed my ASP.NET MVC application on it via the one-click publishing method in Visual Studio 2010, but the IIS server fails to run the application due to a configuration error:

Parser Error Message: Could not load file or assembly 'System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

How do I fix this?

aknuds1
  • 2,095
  • 3
  • 17
  • 23

1 Answers1

7

Apparently I need to install MVC dependencies on the server. I found a recipe on winhost forums, which says to add the required references to your project and configure them for web deployment. I followed these steps, and it solved my problem:

  1. Add the following references to the project:

    • Microsoft.Web.Infrastructure
    • System.Web.Razor
    • System.Web.WebPages.Razor
    • System.Web.WebPages.Deployment
  2. Set the property Copy Local to True for the following references:

    • System.Web.Helpers
    • System.Web.MVC
    • System.Web.WebPages
    • Microsoft.Web.Infrastructure
    • System.Web.Razor
    • System.Web.WebPages.Razor
    • System.Web.WebPages.Deployment
  3. Re-deploy

Edit:

ITHedgeHog made me aware of a shortcut in Visual Studio 2010 for the above procedure: Right click on the project and click Add Deployable Dependencies, you will then get a dialog in which you can simply pick ASP.NET MVC.

aknuds1
  • 2,095
  • 3
  • 17
  • 23
  • IF you're using VS2K10 you can achieve the same thing by right clicking on the project and selecting "Add deployable dependencies" the MVC dependency will be in there to select. – ITHedgeHog Jun 27 '11 at 09:28
  • @ITHedgeHog I am indeed using VS2K10, and this is definitely a preferable shortcut! Would you say this is the recommended approach in general when deploying an MVC project? A colleague told me he would just install the MVC development kit on the server. – aknuds1 Jun 27 '11 at 09:59
  • Personally, it depends on how may MVC Apps you're deploying and if you're going to keep updating MVC on all your apps. If you write one, then bin deploy it - if all your apps are going to be maintained then whack it on the server. – ITHedgeHog Jun 27 '11 at 10:16
  • Useful information thank you. Be aware there is a gotcha where the deployable dependencies will include WebMatrix assemblies. These dlls then resulted in an attempt to redirect to a non-existent login page. Removing them from the bin directory resolved that issue. – David Clarke Sep 19 '11 at 08:47