Question

I have a very strange routing issue.

I have a ASP.NET MVC 3 site using areas. I have the following routes setup in the Assets Area:

public override void RegisterArea(AreaRegistrationContext context)
{
    context.MapRoute(
        null,
        "Assets/{controller}/{action}/{code}",
        null,
        new { code = @"(\w{2,3}$)" }
    );

    context.MapRoute(
        "Assets_default",
        "Assets/{controller}/{action}/{id}",
        new { action = "Index", id = UrlParameter.Optional }
    );
}

When I request the following URLs it works perfectly

http://site.com/Assets/Gallery/GetByCode/AEP
http://site.com/Assets/Gallery/GetByCode/MEC
http://site.com/Assets/Gallery/GetByCode/GP
http://site.com/Assets/Gallery/GetByCode/BR2 
http://site.com/Assets/Gallery/GetByCode/ZZZ 
http://site.com/Assets/Gallery/GetByCode/123

But when I requests this URL I get a "404 - resource can't be found" error

http://site.com/Assets/Gallery/GetByCode/PRN
http://site.com/Assets/Gallery/GetByCode/prn

Every other URL I've tried works - it seems to be just PRN that has issues.

I've put a break point at the beginning of the GalleriesController > GetByCode action, and the PRN route doesn't even try to enter the action (as the 404 error suggests).

Does anyone have any ideas why PRN doesn't work in the route? Or what else I can try to investigate?

Thanks for your help Saan

Was it helpful?

Solution

This may be related to the fact that you can't create the folder "prn" on the Windows file system. My guess is IIS uses the windows file system in such a way that this issue resonates to the described problem above.

In fact, this post may help you: ASP.NET MVC Routing vs. Reserved Filenames in Windows

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top