ActionLink 未生成正确的链接
我正在使用 MVC 2,并且有一个小问题,ActionLink 无法连接到正确的控制器
下面的代码行显示注销链接
<%= Html.ActionLink("Log Off", "LogOff", "Account", new { @class = "loginStatus" })%>
它似乎不会连接到帐户控制器
它所创建的链接是
http://localhost:63262/Centre/Schedule/LogOff?Length=7
:应该有
http://localhost:63262/Authentication/Account/LogOff?Length=7
什么想法吗?
I am using MVC 2, and having a slight issue with the ActionLink not going to the correct controller
The following line of code, which displays a logoff link
<%= Html.ActionLink("Log Off", "LogOff", "Account", new { @class = "loginStatus" })%>
It does not appear to be going to the Account controller
The link it is make is:
http://localhost:63262/Centre/Schedule/LogOff?Length=7
it should be
http://localhost:63262/Authentication/Account/LogOff?Length=7
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请注意您正在调用的 ActionLink() 重载。您认为您正在调用重载 http://msdn.microsoft.com/ en-us/library/dd504972.aspx,但您实际上是在调用重载 http://msdn.microsoft.com/en-us/library/dd492124.aspx。将 null 添加到参数列表的末尾。
Be mindful of the ActionLink() overload you're calling. You think you're calling the overload http://msdn.microsoft.com/en-us/library/dd504972.aspx, but you're really calling the overload http://msdn.microsoft.com/en-us/library/dd492124.aspx. Add a null to the end of your parameter list.
我发现以下链接回答了我的问题,它更多地与区域和路线有关:
http://odetocode.com/Blogs/scott/archive/2009/10/13/asp-net-mvc2-preview-2-areas -and-routes.aspx
这是我的问题的解决方案
I found the following link which answers my question, it's more to do with Areas and Routes:
http://odetocode.com/Blogs/scott/archive/2009/10/13/asp-net-mvc2-preview-2-areas-and-routes.aspx
Here is the solution to my issue