FromUri in WebAPI action does not use JSON.NET JsonParameter to get parameter values

I am working on an GETasp.net WebAPI action to take a complex structure ( GET- this is a requirement):

public class Input
{
    [JsonProperty("a")]
    public string PropA {get; set;}
    ...
}

and my method:

public HttpActionResult Do([FromUri] Input model)
{
   ...
}

If I pass this object using POST with the body - it works fine. Json.NET used to deserialize, and I can pass that object: { 'a': '123' }. But for FromUri(which is required because I have to use GET), I want to pass the following request GET, and it does not work:

../API/v1/controller/do? A = 123

Instead, it works as follows:

../API/v1/controller/do? Propa = 123

Therefore, instead of using my JsonProperty, the FromUri middleware uses the original property names.

- FromUri? ?

+4

Source: https://habr.com/ru/post/1661575/


All Articles