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
精彩评论