0
即時嘗試創建帶段的Html.ActionLink www.example.com/Store* /Segment1/Segment2/Segment3 *。細分是可選的。MVC3:只有控制器和參數的網址(無動作)
IVE定義了以下路線:
routes.MapRoute("Store",
"{controller}/{Segment1}/{Segment2}/{Segment3}",
new
{
controller = "Store",
action = "Show",
segment1 = UrlParameter.Optional,
segment2 = UrlParameter.Optional,
segment3 = UrlParameter.Optional
}
);
行動不應該在URL中可以看到。我似乎無法創建一個有效的鏈接。
在查看我生成的鏈接如下:
<ul>
@foreach (KeyValuePair<string, string> item in ViewBag.LinkList){<li>@Html.ActionLink(item.Key, "Show", "Store", new { item.Value })</li>}
</ul>
當我鍵入adressbar一切網址順利(操作可以讀取段作爲參數),但我不能得到的HTML。 ActionLink正確。 任何人都可以給我一個關於這條路線的ActionLink的例子嗎?謝謝!
謝謝,編輯。這是一個錯誤的帖子,雖然,我的代碼中的路線沒有它:) – stefjnl 2012-02-09 09:50:56
哦,好的。 '@ Html.ActionLink(item.Key,「Show」,「Store」,new {item.Value})'這行看起來不對,'new {item.Value}'不是有效的表達式。 – 2012-02-09 09:54:11
我知道,我需要創建一個動作鏈接,生成類似 〜/ Store/segment1 /。 item.Key是urlname,item.Value是參數 – stefjnl 2012-02-09 09:57:46