我不明白爲什麼ActionLink在這個實例中沒有正確生成url。爲什麼我的ActionLink無法正確生成?
我有一個名爲Activity的控制器和一個名爲Show的視圖。從那裏我試圖創建一個鏈接到ServiceCall控制器,顯示視圖。從上ServiceCall任何視圖中能正常工作:
<%= Html.ActionLink(Html.Encode(sc.CallNumber), "Show", new { callNumber = "100" })%>
從活動看,這是行不通的:
<%= Html.ActionLink(Html.Encode(sc.CallNumber), "Show", "ServiceCall", new { callNumber = "100" })%>
它產生像http://localhost/Activity/Show/12?Length=11
鏈接經過一番研究,我決定試試這個:
<%= Html.ActionLink(Html.Encode(sc.CallNumber), "Show", new { controller = "ServiceCall" }, new { callNumber = "100" })%>
這給了我一個url的http://localhost/ServiceCall/Show但不給callNumber。有任何想法嗎?
這是我的路線:
routes.MapRoute(
"ShowCall",
"ServiceCall/Show/{callNumber}",
new {controller = "ServiceCall", action = "Show", callNumber = ""}
);