1

我正在使用 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

有任何想法吗?

4

2 回答 2

2

请注意您调用的 ActionLink() 重载。您认为您正在调用重载http://msdn.microsoft.com/en-us/library/dd504972.aspx,但您实际上是在调用重载http://msdn.microsoft.com/en-us/图书馆/dd492124.aspx。在参数列表的末尾添加一个null 。

于 2010-02-18T09:00:00.923 回答
1

我发现以下链接回答了我的问题,它更多地与区域和路线有关:

http://odetocode.com/Blogs/scott/archive/2009/10/13/asp-net-mvc2-preview-2-areas-and-routes.aspx

这是我的问题的解决方案

<%= Html.ActionLink("Log Off", "LogOff", "Account", new { area="" }, null)%>
于 2010-02-18T10:30:26.797 回答