ASP.NET MVC 3 Extensionless URLs on IIS 6

A lot has been written about how to get ASP.NET MVC running on IIS 6 with extensionless URLs. Up until now, the story hasn’t been very pretty. When running ASP.NET MVC on ASP.NET 4, it gets a lot easier.

To be fair, the part that makes it easier has nothing to do with ASP.NET MVC 3 and everything to do with a little known new feature of ASP.NET 4 creatively called the ASP.NET 4 Extensionless URL feature. ASP.NET MVC 3 requires ASP.NET 4 so it naturally benefits from this new feature.

If you have a server running IIS 6, ASP.NET 4, and ASP.NET MVC 3 (or even ASP.NET MVC 2. I haven’t tried ASP.NET MVC 1.0), your website should just work with the default extensionless URLs generated by ASP.NET MVC applications. No need to configure wildcard mappings nor *.mvc mappings. In fact, you don’t even need to set RAMMFAR to true. RAMMFAR is our pet name for the runAllManagedModulesForAllRequests setting within the system.webserver setting in web.config. You can feel free to set this to false.

<modules runAllManagedModulesForAllRequests="false"/>

When installing ASP.NET 4, this is enabled by default. So if you have a hosting provider still using IIS 6, but does have ASP.NET 4 installed, then this should work for you, unless…

How does this work?

To be honest, it’s a bit of voodoo magic as far as I can tell and there’s a lot of caveats when it comes to using this feature with IIS 6. There are edge cases where it can cause problems. This is why Thomas Marquardt, the implementor of the feature, wrote a blog post on how to disable ASP.NET 4.0 Extensionless URLs just in case.

In that blog post, he describes the bit of magic that makes this work.

Here’s how the v4.0 ASP.NET extensionless URL features works on IIS 6.  We have an ISAPI Filter named aspnet_filter.dll that appends “/eurl.axd/GUID” to extensionless URLs.  This happens early on in the request processing.  We also have a script mapping so that “*.axd” requests are handled by our ISAPI, aspnet_isapi.dll.  When we append “/eurl.axd/GUID” to extensionless URLs, it causes them to be mapped to our aspnet_isapi.dll, as long as the script map exists as expected.  These requests then enter ASP.NET where we remove “/eurl.axd/GUID” from the URL, that is, we restore the original URL.  The restoration of the original URL happens very early.  Now the URL is extensionless again, and if no further changes are made

He also has a list of conditions that must be true for this feature to work. If any one of them is false, then you’re back to the old extensionfull URLs with IIS 6.

I’m Getting a 403 Forbidden

This is not technically related, but when I tried to test this out to confirm the behavior, I ran into a case where every request was giving me a 403 Forbidden error message. Here’s how I fixed it.

In IIS Manager, I right clicked on the Web Services Extension node and selected the menu option labeled Allow all Web Service extensions for a specific application:

iis6-allowing-extensions

In the resulting dialog, I chose the ASP.NET v4.0.30319 option.

iis6-allow-web-service

To double check that everything was configured correctly, I looked at the properties for my website and ensured that Scripts were enabled.

iis6-home-directory-tab

I also clicked on the Configuration… button and made sure that *.axd was mapped to the proper ASP.NET Isapi dll (aspnet_isapi.dll).

iis6-isapi

iis6-extension-mapping

With all that in place, I was able to run standard ASP.NET MVC web application and make requests for /, /home/about/, etc. without any problems!

What others have said

Requesting Gravatar... Nicholas Piasecki Dec 22, 2010 7:35 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
It is neat, to be sure, but I wish it had been better advertised -- I lost many hours figuring out why our sites were dishing our 404s after moving from .NET 2 to 4, and it was because that new filter functionality broke ISAPI-based URL rewriters like IIRF (because if installed at the site level, the rewriters would "see" the mangled /eurl.axd URL, which the rewrite rules were not written to expect). There's more discussion about it here:

stackoverflow.com/.../3327031#3327031

(Don't meant to a Debbie Downer -- I *love* the initiative to make things simpler, especially since a lot of us are stuck on 2K3 for the time being -- but it really did break a common use case!)
Requesting Gravatar... Phill Dec 22, 2010 8:13 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
I assume this is not limited to MVC3 and can be done for Web Forms in .Net 4.0?
Requesting Gravatar... haacked Dec 22, 2010 8:57 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
@Nicholas Hey Debbie! ;) Sorry it broke you. It's probably a case we just hadn't considered when it was turned on by default.

@Phill Correct. I just tend to focus on ASP.NET MVC scenarios since, well, that's my job. :)
Requesting Gravatar... Brian Dec 22, 2010 10:51 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Just installed this on an IIS6 machine and was up and running in no time. My only issue is I have a route which ends in .xml that’s not fully working. If I add .xml so .net handles it then the route loads and I see my auto generated sitemap, but then actual xml files stop being served up.
Requesting Gravatar... Nova Software Dec 22, 2010 3:14 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Yes, my ASP.NET MVC 3 website works on IIS 6 without extinsion. Thanks very much.
Requesting Gravatar... Felipe Fujiy Dec 24, 2010 3:08 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
The aspnet_filter.dll ISAPI Filter is installed at IIS 7 too?
Requesting Gravatar... amecam Jan 02, 2011 11:07 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
I tried IIS6 & mvc2 on windows server 2003. It is easy to implement the extentionless url feature. The only problem is that it will eat up much more memory than a normal asp.net web form application. But that is ok since I like MVC.
Requesting Gravatar... Thanigainathan Jan 04, 2011 3:29 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Its nice that these kind of thing are taken by defualt in asp.nwt mvc 4. Its really mess when mvc doesn't works in iis 6.

Thanks for letting us know this.

Thani
Requesting Gravatar... Janie Jan 05, 2011 8:56 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Hey
Requesting Gravatar... Kevin Jan 05, 2011 10:29 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Phil,

This is great stuff but I have a question... with this new ability do we still need to do the whole Default.aspx page piece for IIS6 still? I get a directory listing denied when I try without... just curious...

thanks!
Kevin
Requesting Gravatar... haacked Jan 06, 2011 12:17 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
No, you shouldn't need Default.aspx for an MVC app with this.
Requesting Gravatar... Brandon Jan 20, 2011 5:25 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Make sure you have your site in its own App Pool...This blocked my site until I realized it was still in the Default App Pool...
Requesting Gravatar... misaxi Jan 28, 2011 4:54 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
@Brandon I believe it should work even if your app in DefaultAppPool.
Requesting Gravatar... misaxi Jan 28, 2011 5:37 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
I put a little bit attention on the stuff of MVC & IIS 6. And I got a interesting result.

I deploy ASP.NET MVC 2 project (created in VS2010) to IIS 6 on a WIN2K3 server (only .NET Framework 3.5 installed). The only trick I need to do is set 'Copy Local' attribute of System.Web.Mvc assembly to true and no extra work (wildcard mapping, etc). Then the application runs smoothly.

Details on this post.
www.cnblogs.com/...
Requesting Gravatar... arhsim Feb 13, 2011 7:12 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Thanks a lot. I have been banging my head over this for quite some time now.
Requesting Gravatar... Martín Mutilva Feb 14, 2011 3:47 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
I had the following problem: one ASP.Net MVC 2 worked fine in IIS 6 with .Net 4 installed and the another gave me the 403 error.

The difference was the application name (and the directory name): The one that didn't work has dots '.' in its name, e.g. Namespace1.ProjectName.WebMVC.

Changing it to Namespace1_ProjectName_WebMVC solved the problem
Requesting Gravatar... Kevin Jensen Feb 15, 2011 2:23 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
I was able to deploy properly but my app keeps trying to redirect on [Authorize] controllers to /Account/Login even though i'm using windows authentication as stated in my web.config

Here is my web.config: http://pastie.org/1568510
Requesting Gravatar... Mike Edenfield Feb 25, 2011 1:24 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Is this supposed to also work on IIS 5.1?
Requesting Gravatar... Kjeld Poulsen Mar 02, 2011 8:53 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
I tried to host a ASP.NET MVC 3 application as a sub application (virtual directory) where the root was ASP.NET 2.0, using one application pool, while the application it self was using .NET 4.0 in another application pool. I was unable to make this work. As soon as i changed the root application to run .NET 4.0 everything worked as it should.
Requesting Gravatar... doug dexter Mar 10, 2011 1:04 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
I've been trying to get an MVC3 application to run on an XP Pro box with IIS6 for a week now, and haven't been able to do so..

I tried this as well, except for the section regarding Web Services Extension node and i still get the error:

HTTP 401.3 - Access denied by ACL on resource
Internet Information Services

I'm not sure what the security settings on the directory (c:\inetpub\wwwroot\mvc3App) is supposed to be though..

dd
Requesting Gravatar... haacked Mar 11, 2011 12:52 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
@doug Make sure that IUser_MachineName has access to the directories as well as the ASPNET account.
Requesting Gravatar... El Octavo Guerrero Mar 16, 2011 6:51 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
There is no ASP.NET v4.0.30319 option in Web Services and I've installed Net 4 (with Visual Studio 2010).
I get a 403 error.
Requesting Gravatar... jf Mar 23, 2011 5:53 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requesting Gravatar... Bret Ferrier Mar 25, 2011 6:34 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
It looks like this doesn't work with IIS6 if you you are using a Virtual Directory and the Default website is not .Net 4. Is there anyway around this?
Requesting Gravatar... Rui Zhang Apr 11, 2011 11:57 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
I am doing some tests regarding ASP.NET MVC 3, IIS6, and the results are:
Default website .Net 2, virtual directory, MVC 3 app: fails, error code: 403
Default website .Net 4, virtual directory, MVC3 app: passes
Default website .Net 2, existing .Net 2 app; new website.Net 4, MVC3 app: pass
Requesting Gravatar... Schnoz May 08, 2011 11:40 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Any update on the virtual directory issue where the root is running 2.0? My client is getting pretty pissed by now.
Requesting Gravatar... haacked May 09, 2011 12:49 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
@Schnoz I don't understand your question. Perhaps contact MS support if your client is getting upset to get a speedy resolution or ask the question on our forums: http://forums.asp.net/1146.aspx
Requesting Gravatar... Schnoz May 10, 2011 2:40 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Thanks Phil. I did contact support so hopefully we'll get to the bottom of it. But the question is, as per the comments above, that if the root of the site is set to 2.0, the MVC 3 app is not running. If you switch the root to 4.0, the MCV 3 app runs, but it's creating issues with the existing 2.0 applications. This echoes the comments from @Bret and @Rui above, and the comments on this stackoverlow post: stackoverflow.com/.../mvc-3-deployment-to-iis6
Requesting Gravatar... Schnoz May 10, 2011 3:18 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Well, I just got off the phone with support. It turns out that if you still have .NET 2.0 on the root, you still need to configure the Wildcard mapping on the MVC 3 directory. I feel silly now :) Thanks!
Requesting Gravatar... wiiombouwen May 15, 2011 5:38 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Hi,

Does this work on the IIS 5.1? Because it doesn't work with IIS6 on my computer ?
Requesting Gravatar... ldp615 May 28, 2011 4:36 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Help me a lot, Thanks!
Requesting Gravatar... haacked May 29, 2011 1:22 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
@wiiombouwen No, I believe it requires IIS 7
Requesting Gravatar... Vanadiumtech Aug 11, 2011 7:09 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
I ran into a similar issue with v4.0 ASP.Net extension less URL feature on II6 and found a solution through ISAPI Rewrite Module provider, the does not require turning it off. Theissue and the solution as we experienced it is documented here www.vanadiumtech.com/.../Cause-of-eurlaxd.aspx
Requesting Gravatar... IraIsBack Aug 16, 2011 11:54 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
I run on a curious issue with my MVC3 app on a web site virtual directory of IIS 6. I published it from VS2010 (MSDEPLOY) with a virtual directory path on the destination website(wich i assumed will we created on publish). The folder was created on the iis machine but the app didnt work, i got the http 403 (Forbidden), so i tried everything on the previous and current post with no success, the forbidden page still remained.
The solution that worked for me was to clear and recreate de virtual directory on the IIS to an existing folder on then machine, then i published my mvc3 app and it "just worked". Seems VS2010 publish created the virtual directory path with a wrong configuration. ENSURE YOUR DESTINATION PUBLISH PATH EXISTS ON IIS BEFORE PUBLISHING FROM VS2010. RECREATE IT IF NECESSARY.
Requesting Gravatar... DamianR Sep 01, 2011 5:02 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
This didn't work for me. I've been trying to setup a local nuget repository on iis6 win2k3 and after hours of trying all sorts of combinations I still need to browse to Default.aspx manually and the extensionless stuff just doesn't work for me. :(
Requesting Gravatar... Jürg Oct 26, 2011 5:56 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
!!! GREAT IT WORKS FINE !!!
!!! THANKS A LOT !!!
Requesting Gravatar... Gaurav Arora Dec 08, 2011 3:05 AM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
@Haack - thanks for wonderful and informative post. I am thinking in aspect when I will make bin deployment of MVC3 on IIS6.0?

Is there any heck to do the same or its plenty of easy same as with IIS7 or above?
Requesting Gravatar... Craig Howard Jan 17, 2012 3:25 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
I had the same issue on IIS 7.5 and the fix was to set the App Pool to Integrated (instead of Classic)
Requesting Gravatar... Sutikshan Apr 26, 2012 2:35 PM
# re: ASP.NET MVC 3 Extensionless URLs on IIS 6
Thanks. By any chance, do you know anyone who has written powershell to apply these changes (is it possible in powershell?)

What do you have to say?

(will show your gravatar)
Please add 4 and 6 and type the answer here: