Running ASP.NET 4.0 Web Applications on IIS 6

Today, I decided to install a NuGet gallery on our development server at work, in order that we can host our internal packages there, and make them easily available to all projects.  The problem, our development server is not exactly state of the art, and runs Windows Server 2003 SP2 and IIS 6.0.  It did not have ASP.NET 4.0 installed, which is a pre-requisite for the NuGet gallery application.

I was expecting quite a battle to get .Net 4 installed, configured, and working on the server.  My fears were unfounded.  I ran the installer, rebooted, created a virtual directory, set it to ASP.NET version 4.0 (which required an IIS restart, more on this later), published the default “Welcome to ASP.NET” application, and voila!  The result of a HEAD HTTP request to the new virtual directory (note the Server and X-AspNet-Version headers):


The website in action:


It was almost too easy.

So, while I was on a roll, I decided to have a quick play around to find out if it would be easy enough to deploy MVC3 applications to the server.  Unfortunately, it wasn’t quite so easy.  I created another virtual directory and set it to .Net 4.  I was surprised that the system prompted me to restart IIS again – I had assumed that this happened before because it was the first app I’d set to version 4.0.  The prompt gives a hint about running aspnet_regiis –norestart –s <VirtualPath>, but in this case, I didn’t know what the virtual path was.

After a little research, I found out that running aspnet_regiis –lk lists the virtual directories on the server, and this is key to getting hold of the magic number that corresponds to the website.  So, with that info, I was able to run:

aspnet_regiis –norestart –s W3SVC/116872853/root/net4mvctest/

which updated my app to .Net 4 without needing an IIS restart.  Note that your virtual directory path will differ from the above!

MVC3 is not installed on the server, and I had no real wish to install it.  To ensure that my app ran on the server, in Visual Studio I selected the menu item “Project –> Add Deployable Dependences…” and ticked “ASP.NET MVC” and “ASP.NET Web Pages with Razor syntax”.  Now, I deployed.  The result… “Directory Listing Denied”.  Hmmmm.

It turns out that when you deploy a .Net 4 app inside a .Net 2 website, you need to setup a wildcard extension so that .Net handles all requests to the application.  On the application’s property pages in IIS Manager, I clicked “Configure” and inserted a new wildcard map to point to C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll and ensured that “Verify that file exists” was unticked.  Ah, that’s better…


All in all, it took me less than an hour to set all this up, including working through my problems.  I’d say that was a good hour’s work.  Now, I need to get on with configuring and deploying the NuGet gallery…

Recent Related Posts

2 thoughts on “Running ASP.NET 4.0 Web Applications on IIS 6

    • @Mikel,

      Yes, absolutely. There are three ways to use NuGet, and I’m not going to assume anything about your technical ability, so if my answer is too simplistic, or overly complex, just let me know!

      Firstly, I’d point out that for the vast majority of users there is no need to setup your own NuGet feed. The only reason you’d need to is if you want to host your own private packages, or your employer doesn’t want developers to use the full public feed that’s built-in to the package manager in Visual Studio.

      If you do need your own feed, there are three ways you can go about this.

      • Firstly, you can just use a folder on your hard drive as a feed.
      • Secondly, there’s a NuGet package on the public feed called NuGet.Server which is a simple web application which just serves .nupkg files which are dropped into a certain folder. Nothing fancy. Instructions for doing this and the first method can be found here.
      • Finally, there’s a full blown clone of the NuGet gallery website which you can setup. Details instructions for doing so can be found here.

      I took the final approach, and it worked well for me.

Leave a Reply

Your email address will not be published. Required fields are marked *