I don't know what is wrong with my routing configuration.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
but @Url.Action("Index","Agent")
returns
rather than
Please let me know what is missing :)
PS I don't want to disturb the default routing settings ie
Map a route without action = "Index"
before the "Default" route:
routes.MapRoute(
name: "NoDefaultAction",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", id = UrlParameter.Optional }
);
// Code below unchanged
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Now @Url.Action("Index", "Agent")
returns "/Agent/Index"
and "Default" route is undisturbed:
- http://localhost:61759 should route to default page
- http://localhost:61759/Agent should route to http://localhost:61759/Agent/Index
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.