For the past couple of weeks I’ve finally gotten around to playing with the (now not so new) ASP.NET MVC Framework. This, of course, is Microsoft’s take on the MVC architecture pattern which gives developers another well supported and well documented alternative to traditional WebForms projects.
The test machine that I’m running is Windows Server 2003 and IIS 6.0. Unlike more contemporary versions of IIS, it doesn’t support MVC out of the box and leads to the rather annoying problem of 404′s on every page.
The cause of this is that IIS 6.0 expects a physical file to be available every time a URL is called. When it can’t find the files that match the nice URL routes that the MVC framework uses by default it panics and throws the 404. Thankfully there’s a quick configuration change you can make to fix this issue: enabling ASP.NET to manage wildcard URLs.
- Open up the IIS manager
- Open the properties of the site you want to manage
- Click on the Home Directory tab, then the Configuration button
- Click on Insert
- Browse to the ASP.NET ASAPI dll, by default located at:
C:WINDOWSMicrosoft.NETFrameworkv2.0.50727aspnet_isapi.dll - Unckeck the box Verify that file exists
- Click the myriad OK buttons and voilà!
Now, since that was so simple you may be wondering what the catch is. Well the catch is this: the wildcard option has IIS process every request into the server, including static files. Since ASP.NET doesn’t process the files as efficiently as IIS does natively it will cause the application to take a performance hit. If your applications require really high performance, or have a large user base it might be worth considering upgrading to a newer version of Windows and IIS.
This technique was shamelessly paraphrased from the article on Steve Sanderson’s blog which goes into more detail on the hows and whys behind this structure in IIS. Steve also offers a few other options which have their own pros and cons. If you’re making these changes to a production environment I’d recommend you give his article a thorough read.
Enjoy.
