Area folders look like :
Areas
Admin
Controllers
UserController
BranchController
AdminHomeController
Project directories look like :
Controller
UserController
GetAllUsers
area route registration
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" }
);
}
project route registration
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" });
}
When I route like this: http://mydomain.com/User/GetAllUsers
I get resource not found error (404). I get this error after adding UserController to Area.
How can I fix this error?
Thanks...
See Question&Answers more detail:os