First of all, I read this question and this question I think I have another problem. Because everything is the same.
I have MVC5 project. I have 2 areas. First, my default root class like this.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Welcome", action = "Index", id = UrlParameter.Optional});
}
first area route config.
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"App_default",
"App/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
At this point, there is no problem. But I want like this:
This App/Controller
public class AccountsController : Controller
{
// GET: App/Accounts
[Route("app/accounts/list/{Id}")]
public ActionResult List()
{
return View();
}
}
Now, I can access like :
- localhost/Index/Index OK
- localhost/App/Index/Index OK
- localhost/app/accounts/list/45646 ERROR
How can I route attribute using Areas? I cannot do it?