区域的文件夹的样子:
Areas
Admin
Controllers
UserController
BranchController
AdminHomeController
项目目录如下所示:
Controller
UserController
GetAllUsers
地区航线登记
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional },
new { controller = "Branch|AdminHome|User" }
);
}
项目路线注册
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new string[] { "MyApp.Areas.Admin.Controllers" });
}
当我这样的路线: http://mydomain.com/User/GetAllUsers
我得到的资源找不到错误(404)。 我加入到UserController的区域后,出现此错误。
如何解决这个问题?
谢谢...