I am using a RouteValueDictionary to pass RouteValues to a ActionLink:
If I code:
<%:Html.ActionLink(SharedResources.Shared_Pagination_First, Model.ActionToExecute, Model.ControllerToExecute, Model.FirstRouteValues, null)%>
The link result is Ok:
SearchArticles?refSearch=2&exact=False&manufacturerId=5&modelId=3485&engineId=-1&vehicleTypeId=5313&familyId=100032&page=0
But if i code:
<%: Html.ActionLink(SharedResources.Shared_Pagination_First, Model.ActionToExecute, Model.ControllerToExecute, Model.FirstRouteValues, new { @title = string.Format(SharedResources.Shared_Pagination_LinkTitle, 0) })%>
The link result is:
SearchArticles?Count=10&Keys=System.Collections.Generic.Dictionary%602%2BKeyCollection%5BSystem.String%2CSystem.Object%5D&Values=System.Collections.Generic.Dictionary%602%2BValueCollection%5BSystem.String%2CSystem.Object%5D
What’s the problem? The only difference is that in the last i am using htmlAttributes
You are using the wrong overload of the ActionLink helper. There’s no overload that takes
routeValuesas aRouteValueDictionaryandhtmlAttributesas an anonymous object. So ifModel.FirstRouteValuesis aRouteValueDictionarythen the last argument must also be aRouteValueDictionaryor a simpleIDictionary<string,object>and not an anonymous object. Just like that:or