Asp.net-Mvc-3
如何在 ActionLink 中包含書籤/片段?
可能重複:
編碼 :
@Html.ActionLink("Link", "Action", "Controller", new { id = Id } )目前我可以生成這樣的連結:
我想生成這樣的連結:
但我無法編輯路線/創建另一條路線。
什麼是最好的解決方案?
只需使用
proper overloadActionLink 助手:@Html.ActionLink( linkText: "Link", actionName: "Action", controllerName: "Controller", protocol: null, hostName: null, fragment: "divId", routeValues: new { id = Id }, htmlAttributes: null )將產生:
<a href="/Controller/Action/123#divId">Link</a>