I’m using MVC4 and Razor
I am getting unexpected results when I dynamically create a ActionLink and hoping somebody could explain why: The problem is that when I pass null as a htmlAttribute, the URL is generated correctly. However, when I pass in a value, the Area section of the URL are messed up.
<li> @Html.ActionLink(link.LinkText, link.ActionName, link.ControllerName, rvd,link.ActionName.Equals(currentAction) && link.ControllerName.Equals(currentController)? new { @class = "currentMenuItem" }:null)</li>
http://localhost:48000/Accounts/Forum/TopicsGrid?Count=2&Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object%5D&Values=System.Collections.Generic.Dictionary%602%2BValueCollection%5BSystem.String%2CSystem.Object%5D
When I pass null as the htmlAttribute its CORRECT:
<li> @Html.ActionLink(link.LinkText, link.ActionName, link.ControllerName, rvd, null)</li>
http://localhost:48000/Forums/Forum/TopicsGrid/1
ActionLink()does not have aDictionary, Objectoverload.Since your last parameter is an
Object, the routeValues parameter is interpreted as an objetc as well, so it reads the properties of theRouteValudDictionaryclass.