views:

686

answers:

5

I have developed an ASP.NET MVC 2 website, and now need to deploy it to my web server. I've overcome some hurdles already, since ASP.NET was not installed etc. but I've now got to the point where I can serve up plain content files, and if I try to hit one of my MVC URLs I get this:

Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Not surprising, that, as I've not installed MVC2. Problem is, I can't find any good information about how to install it!

The Microsoft Download Center lists 3 files, none of which look promising:

ASP.NET-MVC-2-RTM-Release-Notes.doc

AspNetMVC2_VS2008.exe

mvc2-ms-pl.zip

The site doesn't bother to explain what the files actually are, but I assume that the last file is the source code. That's what it looks like, anyway. The release notes are no help whatsoever, since they're all about installing on your development machine, and indeed the name of the EXE makes it clear that that's all about Visual Studio integration too.

So how do I actually deploy the darn thing?

The other option linked to from Scott Gu's blog is the Microsoft Web Platform Installer. Now, I don't want to install more than just MVC2, and I already have IIS etc. set up, so this seems a bit heavy. But it's all academic, as it refuses to run on my server, saying "your system is not supported" or words to that effect. (The server is Windows Server 2008 Standard SP2, so I really don't know what it's problem is).

Help!

[It's ridiculous that this should be so hard - or perhaps not hard at all, but certainly a well-kept secret!]

+1  A: 

Copy System.Web.Mvc.dll from your development machine to the application's Bin folder on the web server (or to the GAC).

This file comes from AspNetMVC2_VS2008.exe.

SLaks
@SLaks: thanks, if that works then fine. But surely the "correct" place for a "System.*" dll is in the GAC, in which case surely there should be an installer or something for it? Copying the file across like this seems *very* haphazard.
Gary McGill
+5  A: 

To deploy an MVC application, you just need to ensure that you set the references up to copy to your bin folder. Specifically, these DLLs will need to be in there...

System.ComponentModel.DataAnnotations.dll
System.Web.Abstractions.dll
System.Web.Mvc.dll
System.Web.Routing.dll

Note: Copying a reference to your bin folder.

In practice, you do this by following these steps:

  1. Right-click on the reference in the "references" section of your project
  2. Select "Properties"
  3. Locate the "Copy Local" property and set it to "true"

PLEASE NOTE!

System.Web.Abstractions.dll
System.Web.Routing.dll

You only need these two if .NET 3.5 SP1 has not been installed - if you don't have SP1, you will need to include these two dlls, which are part of SP1 and are needed by MVC for routing.

Sohnee
@Sohnee: Presumably System.Web.dll (and others except Mvc) will be there already since I do have ASP.NET?
Gary McGill
@Sohnee: Can you explain what you mean by "set the references up to copy"? I think I know, but for the benefit of others...
Gary McGill
Hello, I've added the copy-local information to the bottom of the answer. I have found that I need to set all 5 of these to copy local.
Sohnee
@Sohnee: thanks. For some reason, I found that I only needed the MVC dll, as the others were already in the GAC.
Gary McGill
Cool - it really depends on the server and what has been installed I guess!
Sohnee
+1  A: 

You do not need to put these files in the Server GAC. You can, but you don't need to.

You can simply copy these files to your /bin directory on the server. In fact, if you have Copy Local set to true when you right click on the reference, it will do just that.

You need to make sure the reference path to this file:

System.Web.Mvc.dll

is in your /bin directory.

George Stocker
+1  A: 

The correct answer is given by Darin Dimitrov in this answer (posted here for your convenience):

You could do a server install which doesn't require Visual Studio installed:

msiexec /i AspNetMVC2.msi /l*v .\mvc.log MVC_SERVER_INSTALL="YES"

Now you are probably asking where's this AspNetMVC2.msi coming from. Actually you download AspNetMVC2_VS2008.exe from here, rename the .exe to .zip and inside you'll find what you are looking for (in the mvcruntime sub-folder).

Eduardo Molteni
A: 

I find running the web platform installer tool works great for getting servers and development machines running. It can be found here... http://www.microsoft.com/web/default.aspx

dionysus55
See my question - it doesn't work on my server for some reason.
Gary McGill