POST json dictionary

后端 未结 10 869
猫巷女王i
猫巷女王i 2020-11-27 05:52

I\'m trying the following : A model with a dictionary inside send it on the first ajax request then take the result serialize it again and send it back to the controller.

10条回答
  •  感情败类
    2020-11-27 06:28

    For anyone who's coming upon this problem recently still, as long as you don't need your controller to specifically accept a dictionary, you can do the following:

    HttpResponseMessage SomeMethod([FromBody] IEnumerable> values)
    {
        Dictionary dictionary = values.ToDictionary(x => x.Key, x = x.Value);
    }
    

    Though it is a bit hacky.

提交回复
热议问题