I have created an Extension function for UrlHelper which simplifies the writing of parameters. It just accept two string parameters and return a string of desired format. In my case it work like this:
public static string CustomAction(this UrlHelper helper, string key, string value)
{
return HttpUtility.UrlEncode("(" + key + "=" + value + ")");
}
The problem I am facing now is when I use this function inside the URL.ACTION more than once it gives me an "invalid anonymous type member decelerator" error. Can someone tell me how can I solve this problem?
Example:
Url.Action("someAction", "someController", new { where = Url.CustomWhereAction("user.ID", Url.UrlParams("id")), Url.CustomWhereAction("person.ID", Url.UrlParams("id")) })
Just to clarify:
Url.UrlParams()
is another Extension function which avoids the programmer to write the code for extracting the routeData values.