0

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.

4

1 回答 1

0

你有

Url.Action("someAction", "someController", new {
 where = Url.CustomWhereAction("user.ID", Url.UrlParams("id")), 
 Url.CustomWhereAction("person.ID", Url.UrlParams("id"))
})

这是您的意思的无效语法

Url.Action("someAction", "someController", new {
 where = Url.CustomWhereAction("user.ID", Url.UrlParams("id")), 
 where2 = Url.CustomWhereAction("person.ID", Url.UrlParams("id"))
})
于 2015-02-10T17:38:32.773 回答