c# - Web API actions to be distinguishable only by their parameter types? -
in asp.net web api, how can 2 actions, both routed same url , same http method, distingushable different parameter types?
i'd able post
either single json object or json array of objects.
i'm expecting work this:
[httppost] public virtual object post([frombody]idictionary<string, object> values) { //add new object collection } [httppost] public virtual ienumerable<object> post([frombody] idictionary<string, object>[] array) { return array.select(post); }
however, if , attempt call either actions, error:
multiple actions found match request
have @ attribute routing library. allows define routes each action in web api. has been packaged part of web api 2.0:
[post("first url here")] public virtual object post([frombody]idictionary<string, object> values) { //add new object collection } [post("second url here")] public virtual ienumerable<object> post([frombody] idictionary<string, object>[] array) { return array.select(post); }
this way able manually define routes each method.
Comments
Post a Comment