I’ve answered several questions about installing ASP.NET MVC 2 on a server lately, and since I didn’t find a full summary I figured it was time to write one up. Here’s a look at some of the top options:
- Bin deploy
- Run the full AspNetMVC2_VS2008.exe installer
- Command-line install with aspnetmvc2.msi
WebPI has quickly become my favorite way to install Microsoft web platform software (including development tools) on my development machine, and it’s a great option for installing on the server as well. I like WebPI for a lot of reasons – here are the top three:
- It’s a tiny download (less than 2 MB)
- It figures out which dependencies you need and which you already have installed, so you get the smallest download and fastest install possible
- It’s one place to go to get all the new releases
So if you have desktop access to the server, probably the best option is to install ASP.NET MVC 2 via WebPI.
ASP.NET MVC was designed so you can use it without needing install permissions, e.g. working with a hosting provider who didn’t have ASP.NET MVC installed. Phil Haack wrote up instructions for Bin Deploying an ASP.NET MVC 1.0 application, and it’s only gotten easier since then. If your server has ASP.NET 4 installed, you’ll just need to set the reference to System.Web.Mvc to “Copy Local”:
If you’re running on .NET Framework 3.5 SP1, you’ll need to include
System.ComponentModel.DataAnnotations.dll (by setting it to Copy Local as well):
And if you don’t have .NET Framework 3.5 SP1, you’ll also need to include System.Web.Abstractions.dll and System.Web.Routing.dll, so the full list to Bin deploy ASP.NET MVC 2 on .NET Framework 3.5 without SP1 is:
For a full walkthrough on this, see Phil’s blog post.
Run the full AspNetMVC2_VS2008.exe installer
The AspNetMVC2_VS2008.exe installer installer is available from Microsoft Downloads at the following (quite memorable) URL: http://www.microsoft.com/downloads/details.aspx?FamilyID=c9ba1fe1-3ba8-439a-9e21-def90a8615a9
I’ll confess that I sometimes forget GUIDs, though, so I always just browse to http://asp.net/mvc and click on the Installer link near the top:
The installer is named AspNetMVC2_VS2008.exe, but it doesn’t require you to have Visual Studio 2008 (or any version of Visual Studio) installed, so it’s just fine to run it on a server. According to Jacques, who works on the installer: On a machine that doesn’t have VSTS/VWD installed, the EXE will autodetect this and only install the runtime component.
There are a few reasons you may not want to use this, though:
- The installer shows a wizard that makes you click through a few steps. You might want to set up a silent / scripted install so you can include it as part of your server build process.
- If the server happens to have VWD or VSTS installed (not a good idea usually, but it’s your server), the installer will also install the MVC tooling. You might not want that.
In those cases, you can do a scripted install with aspnetmvc2.msi.
Scripted install with aspnetmvc2.msi
There’s no direct download link for aspnetmvc2.msi; it’s included in AspNetMVC2_VS2008.exe. The good news is that AspNetMVC2_VS2008.exe is a self-extracting EXE, so you can either open it up with some archive utilities. Apparently it opens with WinRAR, but doesn’t open in either Windows Explorer, and 7-Zip just shows the resource information rather than the actual contents.
None of that’s a problem, though, because it’s a self-extracting exe. That means you can pass a –extract (or –x for short) argument at the command-line to extract it:
You can also specify an extraction directory, like this:
Note: I don’t know of a way to specify the extraction directory in a way that prevents the confirmation prompt from being displayed. Do you?
There are three nested directories inside of the result: mvcruntime, mvctoolsvs2008, and mvctoolsvwd2008. The runtime, not surprisingly, is in the mvcruntime directory.
aspnetmvc2.msi can be run via command-line, and you can pass additional arguments supported by msiexec. Passing /q will specify a quiet install, so no dialogs are displayed. When you’re doing that, you’ll probably want to log the output in case something goes wrong, and you can do that using the /l argument:
C:\Users\Jon\Downloads\AspNetMVC2\mvcruntime>msiexec /i aspnetmvc2.msi /q /l*v .\mvc.log
You can find out more about Windows Installer (msiexec) command-line switches on MSDN, or you can just run msiexec /? to show the help.
You can drop the MVC_SERVER_INSTALL
The ASP.NET MVC 1.0 installer had an additional switch for server installation: MVC_SERVER_INSTALL. This switch is no longer required, because the installer detects if developer tools are installed and automatically falls back to the server install. So you’ll see people recommending that you use
msiexec /i AspNetMVC2.msi /l*v .\mvc.log MVC_SERVER_INSTALL="YES"
to install MVC 2, and while that extra flag won’t hurt anything, it’s completely unnecessary.
Installing on IIS 6
Note: I haven’t been near IIS 6 for a while now, so please let me know if I’m missing something.
Most of the difficulty in setting up ASP.NET MVC 1.0 to work on IIS 6 was in handling extension-less URL’s. Phil wrote up a walkthrough on setting up MVC 1.0 with ASP.NET 3.5 on IIS 6, and there’s a full tutorial on setting up ASP.NET MVC 1.0 with different versions of IIS over at http://asp.net/mvc.
Fortunately ASP.NET 4 takes care of that because it automatically handles extension-less URL’s. Thomas Marquardt has a great blog post explaining how it works under the hood.