开发者

ASP.NET MVC 2 How to pass JSON to ASP.NET Controller Action

开发者 https://www.devze.com 2023-01-15 05:13 出处:网络
Wondering if there is a better way to do this with ASP.NET MVC2. The following Posts on SO are little dated:

Wondering if there is a better way to do this with ASP.NET MVC2. The following Posts on SO are little dated:

How to pass complex type using json to ASP.NET MVC controller

ASP.NET MVC How to pass JSON object from View to Controller as Parameter

and also without using phil haack's futures library in the following post. http://haacked.com/archive/2010/04/15/sending-json-to-an-asp-net-mvc-action-method-argument.aspx

Basically what I am doing right now is using t开发者_如何学Gohe JavaScriptSerializer and deserializing in action/actionfilter.


Phil Haack's post is still up to date for MVC 2 - you need to register a JsonValueProviderFactory to deserialize an object from the posted JSON.

This is baked into MVC 3 already, so I would suggest downloading the MVC 3 preview and taking the JsonValueProviderFactory from the assembly

0

精彩评论

暂无评论...
验证码 换一张
取 消