Hi, I'm trying to add my routing pattern along with the defult routing rules.
routes.MapRoute(
name: "myRouting",
url: "{action}/{controller}/{id}",
defaults: new {action = "Index", controller = "Home", id = UrlParameter.Optional }
);
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "myRouting",
url: "{action}/{controller}/{id}",
defaults: new {action = "Index", controller = "Home", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
With these routing,
http://localhost:29535/Edit/Book ---> Working
http://localhost:29535/Book/Edit ---> Error (The resource cannot be found)
Here, Book is Controller, Edit is Action
But I was expecting both should work.
What I'm basically missing to understand here. Please help me understand the rules behind this.
Note: If I make changes in my url (in myRouting) as
url: "{action}/2/{controller}/{id}",
http://localhost:29535/Edit/2/Book ---> Working
http://localhost:29535/Book/Edit ---> Working
Thanks,
Prabhu