ASP.NET MVC routing when a controller's and folder's names are the same

If a controller, say FooController, has the same name as an existing folder, say /foo, then what must be done so that requests for http://example.com/foo serve the controller's Index view?

Additional Information

EDIT

I am leery of using RouteExistingFiles based upon what I have read in a number of places (including this very similar Stackoverflow question). Is another, less severe, option available?

Upvotes: 2

Views: 1798

Answers (1)

imGreg
imGreg

Reputation: 900

Do not name folders and controllers the same name because it causes routing problems. The main problem is when its looking for the view its going to all possible paths that it knows of to find for your index in a controller called foo but since you also have a folder called foo it apparently found that first and assumed it was in there. I do not suggest changing the route config in order for your current setup to work. I would suggest changing the folder name or controller to something else.

Upvotes: 1

Related Questions