msgbartop
A site for my programming pet projects
msgbarbottom

06 Nov 08 Extensionless urls in ASP.NET MVC on IIS 6

I recently started playing around with ASP.NET MVC to build a small website. I’m pretty impressed, I like working with MVC a lot better than the web forms model. One thing that ASP.NET MVC offers is to have “pretty urls” similar to frameworks like Ruby on Rails or Django, that is, instead of urls that look like http://example.com/index.aspx?car=Ford&year=1990 you get urls like http://example.com/cars/Ford/1990. This works flawlessly in Visual Studio using the development webserver but there can be some complications when deploying to IIS. The new IIS 7 has support for this built in when using integrated mode, however my webhost is still on IIS 6 and there are problems there. Essentially there are two ways that can be used with IIS 6. The first way is to map all requests to the ASP.NET engine, even ones for images, css etc. That works but has some performance implications. The other way is to use a file extension in all urls, so our example url might have to be something like http://example.com/cars.aspx/Ford/1990/. That’s not horrible but not the way I want it either. So, I came up with another way. (more…)