Published in: http://www.birchlee.com/post/2011/10/12/15.aspx
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/IndexOutput after runningAdmin/home/Index
Http: // localhost: 49849/OA/home/IndexOutput after runningOA/home/Index
Change path:
Http: // localhost: 49849/admin/404 error reported later
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.