Mvc4 routing action not able to display action

I am having trouble trying to get a route that works in the area I have.

My area is called ABC, and I have a controller called Home inside the area. I can hit a breakpoint with Home / Index if I look at "http: // localhost: 8000 / abc", however, when I try to click another action called "http: // localhost: 8000 / ABC / details", I get 404.

I tried

context.MapRoute(
           "details",
           "ABC/Home/{action}/{id}",
           new { action = "details", id = UrlParameter.Optional },
             constraints: null,
           namespaces: new[] { "WebApplication.Areas.ABC.Controllers" }

       );



        context.MapRoute(
          "ABC_Home",
          "ABC/{controller}/{action}/{id}",
          new { controller = "home",action="Index", id = UrlParameter.Optional },
            constraints: null,
            namespaces: new[] { "WebApplication.Areas.ABC.Controllers" }
      );

This allows me to hit the action if I use "http: // localhost: 8000 / ABC / Home / Details"

 context.MapRoute(
           "details",
           "Home/Home/{action}/{id}",
           new {controller="home", action = "details", id = UrlParameter.Optional },
             constraints: null,
           namespaces: new[] { "WebApplication.Areas.ABC.Controllers" }

       );

Ideally, I don't want to use the house in the URL, if possible. What am I doing wrong?

Any help would be awesome!

+3
source
2

, . , , /ABC; :

context.MapRoute(
    "ABC_Home",
    "ABC/{action}/{id}",
    new { controller = "home", action="Index", id = UrlParameter.Optional },
    constraints: null,
    namespaces: new[] { "WebApplication.Areas.ABC.Controllers" }
}

/abc /home/index, /abc/details /home/details.

, , , - :

context.MapRoute(
    "Default_Route",
    "{controller}/{action}/{id}",
    new { id = UrlParameter.Optional }
}
+3

, . , , . , :

Context.MapRoute(
    "ABC_Home_Details",
    "ABC/Details/{id}",
    new { controller = "home", action="details", id = UrlParameter.Optionsl },
    constraints: null,
    namespaces: new [] { "WebApplication.Areas.ABC.Controllers" }
);
0

All Articles