views:

128

answers:

2

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?

A: 

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.

Levi
A: 

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

<%= Html.ActionLink("Log Off", "LogOff", "Account", new { area="" }, null)%>
Coppermill

related questions