3

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 the JavaScriptSerializer and deserializing in action/actionfilter.

Community
  • 1
  • 1
sdon
  • 31
  • 2

1 Answers1

0

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

Russ Cam
  • 124,184
  • 33
  • 204
  • 266
  • I can't use MVC 3 preview for a production App. Also using MVC futures is not an option :( – sdon Sep 06 '10 at 19:55
  • I'm not suggesting using MVC3 in your app, just the JsonValueProviderFactory class from the assembly. or you could write your own instead :) – Russ Cam Sep 06 '10 at 20:53