开发者

Strongly typed Html.ActionLink<T>() helper extension from MVC Futures doesn't do well with areas

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).

Th开发者_StackOverflowis 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 error lies here:

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

So it's actually the default behaviour of the HtmlHelper.


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().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜