Reputation: 4758
How do I specify a default action for an area
I have defined my area and its working ok
/admin/
however if I browse to /admin/ directly it seems to hit standard controller and not the area and there is no standard controller area thus it 404's
Is there a way to specify the area has a default controller / action or do I need to define a custom route.
Upvotes: 1
Views: 182
Reputation: 2590
You can do this by specifying the area
in RegisterArea
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"admin", // Route name
"admin/{controller}/{action}/{id}", // URL with parameters
new { controller = "YourControllerName", action = "YourActionName", area = "admin", id = UrlParameter.Optional } // Parameter defaults
);
}
Now if you browse to admin
, it will redirect directly to the action specified in RegisterArea
Upvotes: 2