Reputation: 1255
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
FooController's
Index.cshtml
view.routes.MapRoute("Default",
"{controller}/{action}/{id}", new { controller = "Home", action =
"Index", id = UrlParameter.Optional }
) is set up and working.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
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