The project is divided into three home pages
For example:/Home/Index front-end Homepage
/Admin/Home/Index background Homepage
/OA/Home/Index Office Platform Homepage
Create an asp.net MVC3 example project: Right click → add → Area
Run the project directly:
The reason is that multiple controllers with the same name exist, and the default namespace needs to be configured. Solution:
Open Global. asax. cs
Public static void RegisterRoutes (RouteCollection routes)
{
Routes. IgnoreRoute ("{resource}. axd/{* pathInfo }");
Routes. MapRoute (
"Default", // Route name
"{Controller}/{action}/{id}", // URL with parameters
New {controller = "Home", action = "Index", id = UrlParameter. Optional}, // Parameter defaults
New [] {"Web. Controllers"} // Namespaces introduces the default namespace
);
}
Http: // localhost: 49849/output after runningHome/Index
Http: // localhost: 49849/Admin/Home/Index output after runningAdmin/Home/Index
Http: // localhost: 49849/OA/Home/Index output after runningOA/Home/Index
Change path:
Http: // localhost: 49849/Admin/www.2cto.com and the system Returns Error 404.
The reason is that the Admin in Area does not configure the default Controller. solution:
Open Admin under AreaAdminAreaRegistration. cs
New {controller = "Home", action = "Index", id = UrlParameter. Optional}
Add the default Controller.
Here, I will discuss it.
From: BirchLee's personal blog