如何在 ASP.NET MVC 2.0 beta 区域中获取绝对根链接?

发布于 2024-08-12 23:09:55 字数 503 浏览 5 评论 0原文

用于登录的链接如下所示:

<%= 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感受沵的脚步 2024-08-19 23:09:55

请尝试使用 RouteLink

Try RouteLink instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文