MVC AreaRegistration
AreaRegistration.RegisterAllAreas(); You may have seen it under Application_Start event. What it does?
There might be multiple sections like Administrator, Users, Bloggers, Writers, Advertise, Forums, Billing or department and so on of your web application. It becomes very difficult to manage all controllers at one place. So there is a way to register such areas and add controllers init.
Right click on MVC project to add new Area
Add new Area and name it as Administrator.
This will create Model, view and controller folder structure for you along with web.config.
And form here you are free to add your controllers and views specific to Administrator section.
using System.Web.Mvc;
namespace Req.Web.Api.Areas.Administrator
{
public class AdministratorAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Administrator";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Administrator_default",
"Administrator/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}
}
Note: When you create new area inside an application, it creates new class derived from AreaRegistration. A new class overrides areaname property and it also registers routes for it.