HtmlHelper ActionLink 省略区域 (asp.net mvc 4)
我在生成链接时遇到问题 我有一个名为“Administration”的区域,它还有一个 HomeController 作为根, 在母版页中
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("Admin", "Index", "Home", new {area = "Administration"})</li>
我也继承了From Route,方法GetVirtualPath接受参数值 它省略了区域键,仅传递控制器和操作。
我哪里做错了?
I have problem with generation of links
I have an Area named "Administration", it also has a HomeController as a root,
In the masterpage
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("Admin", "Index", "Home", new {area = "Administration"})</li>
Also I inherited From Route, and the method GetVirtualPath accepts the parameter values
which omits area key, and passes only controller and action.
Where did I go wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您使用了不正确的过载。您应该使用 LinkExtensions.ActionLink 方法(HtmlHelper、String、String、String、Object、 Object) (注意最后的最后一个参数)
You use incorrect overload. You should be using LinkExtensions.ActionLink Method (HtmlHelper, String, String, String, Object, Object) (note the last parameter at the end)
问题解决了,并且出现在 DataTokens 中。我仅为区域定义区域,而不为根中的控制器定义区域。
现在可以了。谢谢!
The problem solved, and was in DataTokens. I was defining area only for areas, but not for controllers in the root.
Now it works. Thanks!