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.

1
  • This is very actual for me, either! Commented Sep 21, 2010 at 17:20

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

I can't use MVC 3 preview for a production App. Also using MVC futures is not an option :(
I'm not suggesting using MVC3 in your app, just the JsonValueProviderFactory class from the assembly. or you could write your own instead :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.