如何附加到这样的网址
mysite.com/articles/1/my-first-article
具有div id #commentList
的元素mysite.com/articles/1/my-first-article#commentList
<%: Html.ActionLink("text", "action", new {/* ??? HOW TO SET IT HERE ??? */})%>
答案 0 :(得分:2)
尝试使用proper overload(带片段的那个),这将允许您生成包含片段部分的所需网址:
<%= Html.ActionLink(
"some text", // linkText
"articles", // actionName
null, // controllerName
null, // protocol
null, // hostName
"commentList", // fragment <-- that's what you need
new { id = 1 }, // routeValues
null // htmlAttributes
) %>