我在ASP.net MVC是新Asp.net MVC 5路由
我的路由配置是这里
routes.MapRoute(
name: "ItineraryRoute",
url: "{country}/Itinerary/tours/{TourId}",
defaults: new { controller = "TourDetails", action = "Index" }
);
routes.MapRoute(
name: "TourRoute",
url: "{country}/tours",
defaults: new { controller = "Tour", action = "Index" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
在/Russia/tours
页我这里有一个环节是代码行:
<a href="@ViewBag.Country/tours/Itinerary/@tour.Id">Day's By Detail's....</a>
当我点击这个,页面会链接到这个网址:/Russia/Russia/tours/Itinerary/1
因错误404未找到http。
你有什么想法,为什么我有两个俄罗斯,如何解决它与'TourId'的'TourDetailsController'链接?
Perpend一个'/'。但是你应该总是使用'@ Url.Action()'或'@ Html.ActionLink()'来产生正确的URL。 –
是否可以回答这个问题,并告诉我在这种情况下如何使用'@ Html.ActionLink()'? –
我不知道该如何谢谢你。谢谢 。 –