1

I have run into a strange issue where any URL containing "PRN" will return a 404.

If I have 2 methods:

    public string Test(string x)
    {
        return "hello";
    }

    public string PRN(string x)
    {
        return "worked";
    }

I can call test by navigating to: Controller/Test

It will always return "hello." However, if I try to call: Controller/Test/PRN, I get a 404

If I attempt to call Controller/PRN/Anything, I get a 404

In multiple MVC3 applications, I have found that any URL containing "PRN" will return a 404 error. Does anyone have any ideas?

EDIT: This is my route configuration:

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
        );

    }

Thanks.

RepDetec
  • 741
  • 13
  • 29

2 Answers2

5

You should have a read a this : http://bitquabit.com/post/zombie-operating-systems-and-aspnet-mvc/

Which points to : ASP.NET MVC Routing vs. Reserved Filenames in Windows

Community
  • 1
  • 1
mathieu
  • 30,974
  • 4
  • 64
  • 90
-1

If you call Controller/Test/PRN' It wont point to anything because you are calling theTest` ActionMethod and passing PRN as the parameter.

Try adding ...

routes.MapRoute(
            "PRN", // Route name
            "Controller/PRN/{x}", // URL with parameters
            new { x = UrlParameter.Optional } // Parameter defaults
        );

... to the top of your RegisterRoutes method in Global.asax.cs folder.

Stephen__T
  • 2,004
  • 3
  • 25
  • 48
  • I understand that, but "PRN" should work fine as a parameter. If I call Controller/Test/SomethingThatIsntPRN, it returns "hello" as I would expect. – RepDetec Jul 06 '11 at 13:48