Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC controller gives me a 403 forbidden error with the default route when it's called DocumentationController

Tags:

asp.net-mvc

Is DocumentationController reserved for system usage or something?

I created a blank MVC app, created a DocumentationController with corresponding view. It works if I go to www.mysite.com/Documentation/Index but if I go to www.mysite.com/Documentation/ then I get a 403 forbidden.

Renaming DocumentationController to Documentation2Controller and associated views, it (the default route, etc.) works perfectly.

Is it a reserved keyword or could there be another reason why it doesn't pick up the default route?

like image 418
NibblyPig Avatar asked Jul 02 '14 14:07

NibblyPig


2 Answers

Make sure you don't have an actual virtual/physical directory named Documentation.

You can also instruct MVC to 'take over' the request even when it matches a directory by setting the RouteExistingFiles flag to true (in your Routes configuration):

public static void RegisterRoutes(RouteCollection routes)
{
    routes.RouteExistingFiles = true;

    //...
}
like image 138
haim770 Avatar answered Nov 16 '22 02:11

haim770


There is no problem using this word as controller name. (At least in ASP.NET MVC3)

The only reserve words are these: http://bitquabit.com/post/zombie-operating-systems-and-aspnet-mvc/

like image 24
Artur Kędzior Avatar answered Nov 16 '22 03:11

Artur Kędzior