Getting MVC 4 running on Server 2003

For many of us, just updating to the latest Server software isn’t in all cases an option.

Make sure .NET 4.0 is installed.

The most reliable way to check the .NET framework and service pack versions is to consult the registry.
This is a good table that will tell you this.
If you find .NET 4.0 isn’t installed, you’ll have to download and install it.

Make sure ASP.NET 4.0 is activated for your web site

First you’ll need your web sites SiteID.
Open IIS Manager.
Click the Web Sites folder in the left pane. In the right pane, you’ll see all your web sites listed.
There should be a column called “Identifier”. The fields beneath are the web sites SiteID’s.
Take note of your web sites Id.

Navigate to ASP.NET’s default path C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
You’ll then need to run the following command:

aspnet_regiis -lk | find "Id"

Where “Id” is your web sites Id as you recorded above.
You need the quotes too.

This should produce the following:

"W3SVC/Id/ROOT/ [your .NET framework version number]"

That’s what your website’s virtual path in IIS6.0 looks like with the .NET framework version tacked on the end, without the quotes.
Id of course will be your web sites Id.

If the .NET framework version isn’t v4.0.30319, you’ll need to register it.
Run the following command:

aspnet_regiis.exe -norestart -s "W3SVC/Id/ROOT/"

Id is once again your web sites Id.
This should register ASP.NET 4.0 with your web site.
IIS won’t need restarting.

Make sure the App pool your web site is going to run in is dedicated to .NET 4.0

Here’s some doc for aspnet_regiis.exe

Make sure ASP.NET MVC 4 is installed on the target machine

or the project is set to bin deploy
I prefer to bin deploy, so we don’t clutter up the old server.
Any additional libraries I need,
I include by using NuGet at solution level,
This allows many projects to use the same packages.

It looked like after some research,
but before I actually started on this,
that we would run into this problem, but no,
It turned out that our .NET 4 ASP.NET ISAPI extension was already enabled.

File extension mapping

The file extension in the URL (.aspx for example) must be mapped to aspnet_isapi.dll.
If it is, and there’s a .aspx in the URL,
aspnet_isapi.dll invokes ASP.NET.
If ASP.NET is invoked, (because UrlRoutingModule is a .NET IHttpModule) UrlRoutingModule gets invoked.

IIS 6 only invokes ASP.NET when it sees a “filename extension” in the URL that’s mapped to aspnet_isapi.dll
This means we have to do some work to get IIS 6 to recognise files that don’t have this mapping.
As this was a test deployment, I wasn’t too concerned about speed.
So decided to use wildcard mapping for aspnet_isapi.dll, as it was the easiest to setup.

Open IIS Manager

1. Right click on your web app and select Properties
2. Select the HomeDirectory tab
3. Click on Configuration

4. Under the Wildcard application maps edit box,
—-click Insert (not Add)
5. Enter C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
—-\aspnet_isapi.dll for the “Executable:”
6. Uncheck “Verify that file exists”

7. Click OK, OK

There are a few ways of achieving a similar result.
Here are some ideas:

http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
http://blog.stevensanderson.com/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/
Another resource that’s well worth a read is the “Test Drive ASP.NET MVC” book.
In chapter 12 it talks a little about this also in the section… IIS 6.0 on Windows Server 2003 or XP Pro x64

Advertisements

13 Responses to “Getting MVC 4 running on Server 2003”

  1. Rich Says:

    Is this assuming that this is the first time MVC of any version is installed on this server or is this upgrading from a prior version of MVC? I ask because we are running MVC 3 apps on Win2k3.

    Thanks!

  2. binarymist Says:

    The server had not had any MVC apps running on it before I undertook this process, but the process should still act as a guide if you are trying to setup for running an MVC4 app.
    There are some obvious steps here that would need to be performed regardless of what was on there before.

  3. Lelala Says:

    Wow, thanks for that insightful post – exactly what i need! THANKS a lot, saved a lot of headache 🙂
    Regards

  4. Adam Prescott Says:

    This worked for me, too. Thanks!

  5. Pieter Says:

    5. Enter C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
    —-\aspnet_isapi.dll for the “Executable:”

    Do you mean \v4 as in the screenshot?

    Thanks for these steps, making my life so much easier 🙂

  6. Vilgan Says:

    This was extremely helpful, Thanks!

  7. foundmyselfat Says:

    I’m pulling my hairs out the last 2 days and follow all the steps here as well as from haacked and I still couldn’t get it up running and still have “The page cannot be found”

    Any suggestion as to where else I need to check ? I’m developing a MVC 4 Mobile App and trying to deploy it onto IIS6.0 on Window Server 2003

    Much appreciated

  8. foundmyselfat Says:

    I have followed all the steps here as well as on haacked but still couldn’t get it run. I’m trying to deploy a MVC4 Mobile App onto IIS6.0 on Windows Server 2003.

    Any suggestion as to where else I need to check ?

    much appreciated !

    Anne

  9. Trevor Bechard Says:

    Thank you!

  10. Miguel Isidoro Says:

    Nice article. step 5 you must change from C:\WINDOWS\Microsoft.NET\Framework\v2.0.5072\aspnet_isapi.dll to C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
    \aspnet_isapi.dll.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: