如何在 ActionLink 中包含书签/片段? [英] How can I include a bookmark/fragment in an ActionLink?
本文介绍了如何在 ActionLink 中包含书签/片段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能的重复:
在 asp.net mvc 中包含锚标记Html.ActionLink
代码:@Html.ActionLink("Link", "Action", "Controller", new { id = Id } )
目前我可以生成这样的链接:
For the moment I can generate links like this :
http://mywebsite/Controller/Action/Id
我想生成这样的链接:
http://mywebsite/Controller/Action/Id#divId
但我无法编辑路线/创建另一条路线.
But I can't edit the route/create another route.
最好的解决方案是什么?
What is the best solution?
推荐答案
只需使用 正确重载
ActionLink 助手:
Just use the proper overload
of the ActionLink helper:
@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>
这篇关于如何在 ActionLink 中包含书签/片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文