0

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

  1. Is URL.Action depends on the routing?
  2. 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

mintssoul
  • 51
  • 1
  • 10
  • possible duplicate of [Can I change all my http:// links to just //?](http://stackoverflow.com/questions/4831741/can-i-change-all-my-http-links-to-just) – Jeremy J Starcher May 27 '15 at 06:19
  • There is a fair discussion on the effects of leaving the protocol off that is linked to when I flagged your question as a duplicate. – Jeremy J Starcher May 27 '15 at 06:20

0 Answers0