How to bind URL parameters to model properties with different names

后端 未结 5 1151
你的背包
你的背包 2020-12-16 01:18

Okay, lets say I have a URL like so, which is mapped via HTTP verb GET to the controller action I have below:

GET /foo/bar?sort=asc&r=true
<         


        
5条回答
  •  一生所求
    2020-12-16 01:21

    You could implement IModelBinder to map your incoming parameters to the object of your choosing provided the incoming parameter names are defined. Otherwise you would have to rely on parameter order and/or type to infer the proper binding which seems to be a very poor choice.

提交回复
热议问题