可能重复:
Including an anchor tag in an asp.net mvc Html.ActionLink
代码:@Html.ActionLink("Link", "Action", "Controller", new { id = Id } )
目前我可以生成这样的链接:
我想生成一个这样的链接:
但我无法编辑路线/创建另一条路线。
什么是最佳解决方案?
答案 0 :(得分:15)
只需使用ActionLink助手的proper overload
:
@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>