I would like to revise the questions here, my focus is on MVC Url.Action:
I am testing on Url.Action
in view http:// localhost:22334/Order/Index
@Url.Action("Summary", "Order")
When the route config is
routes.MapRoute(
name: "Order",
url: "{lang}/Order/{action}",
defaults: new { lang = UrlParameter.Optional, controller = "Order", action = "Index" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{*pathInfo}",
defaults: new { controller = "Order", action = "Index", id = UrlParameter.Optional }
);
It generate a link //Order/Summary
which is not working
However when the Route Config is added with constrait
routes.MapRoute(
name: "Order",
url: "{lang}/Order/{action}",
defaults: new { lang = UrlParameter.Optional, controller = "Order", action = "Index" },
constraints: new { lang = "[a-z]{2}" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{*pathInfo}",
defaults: new { controller = "Order", action = "Index", id = UrlParameter.Optional }
);
It generate a link /Order/Summary
which works well
- Is URL.Action depends on the routing?
- Since I am testing on localhost, will URL.Action generate different result when I put on server like 'http://myserver/myapps/ordersystem/Order/Index
Thanks
Best Regards,
mintssoul