problem is focused on, regional control product name repetition of the name and the root directory to how to solve, don't tell me change the name to oh, see what solutions
RouteConfig. Cs file content
Public static void RegisterRoutes (RouteCollection routes)
{
Routes. IgnoreRoute (" {resource} axd/{* pathInfo} ");
Routes. The MapRoute (
Name: "Default",
Url: "{controller}/{action}/{id}",
Defaults: new {controller="Home", action="Index", id=UrlParameter. Optional},
Namespaces: new string [] {" XXX. WEB. Controllers "}//added the other controller can access the root directory,
);
}
This is area under the routing file
AdminAreaRegistration. Cs
Public class AdminAreaRegistration: AreaRegistration
{
Public override string AreaName
{
The get
{
Return "Admin";
}
}
Public override void RegisterArea (AreaRegistrationContext context)
{
The context. The MapRoute (
"Admin_default,"
"Admin/{controller}/{action}/{id}",
New {action="Index", id=UrlParameter. Optional},
New string [] {XXX. WEB. Areas. Admin. "Controllers"}
);
}
CodePudding user response:
Your routing rules are not all write very clear, the root directory is/Controller/Action, Areas are in the directory/Admin/Controller/ActionCodePudding user response:
In general, as long as controller name is not the same, the name of the area and the controller with the same name is not too bigCodePudding user response:
Regional configurationPublic override void RegisterArea (AreaRegistrationContext context)
{
The context. The MapRoute (
Enclosing AreaName + "_Default,"
Enclosing AreaName + "/{controller}/{action}/{id}",
New {area=this. AreaName, controller="Home", action="Index", id=UrlParameter. Optional},
New string [] {+ "XXXXX. Web. Areas." this. AreaName + "Controllers"}
);
}