I set the default route object to a controller (“Beheer”) inside an area (also called “Beheer”).
Like this:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Beheer", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
It can find that controller and the action fine inside the Area, but it can not find the view because it only looks in these locations:
~/Views/Beheer/Index.aspx
~/Views/Beheer/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Beheer/Index.cshtml
~/Views/Beheer/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
While it should be looking in this location:
~/Beheer/Views/Beheer/Index.aspx
How can I make it search for the view there?
I already tried:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { area = "Beheer", controller = "Beheer", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
And I tried this (with namespaces):
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Beheer", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new[] { "Areas.Beheer" }
);
But nothing changes. It enters the correct action in the correct controller but can’t find the view.
You should add your route in the area registration. BeheerAreaRegistration has a property that sets the area name.