如何在 ASP.NET MVC 2.0 beta 区域中获取绝对根链接?
用于登录的链接如下所示:
<%= Html.ActionLink("Log On", "LogOn", "Account") %>
这会在浏览器中生成以下链接:
http://localhost:2300/Account/LogOn
但是,如果我切换到 Area
,例如 Content
,则登录链接现在看起来如下像这样:
http://localhost:2300/Content/Account/LogOn
...这当然会失败,因为 Content
区域中没有 AccountController
。
如何更改对 ActionLink 的调用,使其生成 http://localhost:2300/Account/LogOn
?
The link for logging in looks like this:
<%= Html.ActionLink("Log On", "LogOn", "Account") %>
which yields the following link in the browser:
http://localhost:2300/Account/LogOn
However, if I switch to an Area
, such as Content
, the Login link now looks like this:
http://localhost:2300/Content/Account/LogOn
...which fails of course, because there is no AccountController
in the Content
Area.
How do I change my call to ActionLink so that it yields http://localhost:2300/Account/LogOn
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请尝试使用 RouteLink。
Try RouteLink instead.