Using Area in MVC you can split large application structure into small groups.
Each Area itself contains a MVC folder structure and in routing you need to add additional parameter 'area'.
e.g: http://localhost/AreaExample/Home/Index
AreaExampleAreaRegistration.cs
What if more the one Area have same controller name ?
How you can define default area in routing for application?
In RouteConfig.cs you need to add additional parameter 'namespaces' in MapRoute.
eg:
RouteConfig.cs
Hope it help you to understand the basic concept of Areas and it's routing structure.
Each Area itself contains a MVC folder structure and in routing you need to add additional parameter 'area'.
e.g: http://localhost/AreaExample/Home/Index
AreaExampleAreaRegistration.cs
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
name: "AreaExample_default",
url: "AreaExample/{controller}/{action}/{id}",
defaults: new {controller="Home", action = "Index", id = UrlParameter.Optional }
);
}
What if more the one Area have same controller name ?
How you can define default area in routing for application?
In RouteConfig.cs you need to add additional parameter 'namespaces' in MapRoute.
eg:
RouteConfig.cs
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new [] { "LearnOnlineAspNet.MVCexample.Areas.AreaExample.Controllers" }
);
}
Hope it help you to understand the basic concept of Areas and it's routing structure.