Why In registerroute method we need to maintain sequence?
i,e default route mapping should be placed at the last .Say i have two url routing(Map1, Map2) as below
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//Map 1
routes.MapRoute(
"CustomUrm",
"MyUrl/{Category}/{Id}", // URL with parameters //
new { controller = "Home", action = "MyAction", Category = "xyz", Id = 2 });
//Map 2
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional} );
}
By default Controller "Home" with action method "Index" wil be called while running the application(Say in URL its"http://localhost:63263/")
Then in url i am typing "http://localhost:63263/MyUrl" then its calling action method "MyAction" of controller "Home".
But if i am changing the url mapping sequence(Map1 and Map2) then with URL "http://localhost:63263/MyUrl" it is showing error : resource not found, Requested URL: /MyUrl.
Thanks
Francis SusaimichaelPosted Oct 22, 2015, 9:44 PM
Arul RPosted Oct 23, 2015, 7:26 AM
Francis SusaimichaelPosted Oct 23, 2015, 2:07 AM
Priyaranjan K SPosted Oct 23, 2015, 1:23 AM
Debsankar PatraPosted Oct 23, 2015, 1:03 AM
Debsankar PatraPosted Oct 22, 2015, 12:03 PM
Francis SusaimichaelPosted Oct 22, 2015, 9:00 AM