views:

318

answers:

1

Hi,

I noticed some odd behaviour when using the strongly typed HtmlHelper.ActionLink() extension method from ASP.NET MVC 2 Futures. When I use it to link to a controller in an area I have to use the following attribute on this controller

[ActionLinkArea("SomeArea")]

It links properly to the actions of the controller located in SomeArea from the default area. The problem is when I want to link back to a Controller action located in the default area from within SomeArea. The link appears with "/SomeArea/" prefix. The workaround I use is:

[ActionLinkArea("")]

on the controller on all controllers that are located in the default area (using inheritance).

This seems odd because in my opinion that should be the default behavior of this method. Using .NET Reflector on this extension method I noticed that the arror lies here:

return helper.RouteLink(linkText, routeValuesFromExpression, new RouteValueDictionary(htmlAttributes));

so it's actually the default behaviour of the HtmlHelper.
Have you encountered this problem - maybe there's a cleaner solution?

Best regards,
Max

+1  A: 

Known issue in MVC 2 Futures - same underlying cause as http://forums.asp.net/p/1535698/3732346.aspx.

From our internal database, if you wanted to patch the file and recompile MVC Futures yourself:

The bug is in LinkBuilder.cs, line 21. The method call GetVirtualPath() should be GetVirtualPathForArea().

Levi
I think I'll do that - thanks!
brainnovative