2

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

4
  • does your Index action get hit instead? Commented Sep 17, 2012 at 12:47
  • Have you tried removing the regex restraint on the route? Have you also tried putting the parameters in the same order as they are in the default route? Commented Sep 17, 2012 at 13:31
  • Yep, tried hard coding a constraint of context.MapRoute(null, "Assets/Gallery/GetByCode/PRN", new {controller="Gallery", action="GetByCode", code="PRN" ); and it still didn't work Commented Sep 17, 2012 at 16:42
  • Woah. That's weird. No idea whats going on there! Sorry! Commented Sep 17, 2012 at 17:37

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.