How to force web API to recognise querystring parameter

前端 未结 2 1783
半阙折子戏
半阙折子戏 2021-02-19 11:00

ASP.NET MVC4 Web API v1 controller is defined below. It should accept 1 or 2 query string parametrs.

However ko parameter is always null if method is called. Request is

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-19 11:28

    Another option is to implement a custom type provider. This allows control over the representation in the query string, and means you don't have to add the [FromUri] attribute to your action methods. This makes sense if you have widespread reuse of a complex parameter type, or need a custom representation.

    A good example of this is given in this blog post where a location with latitude and longitude is implemented using both techniques.

提交回复
热议问题