0

In MVC 4, action methods can have parameters of specific complex types. If the incoming JSON can be matched to that complex type, the action method is invoked with the deserialized value. When it works, it works very smoothly.

I'm interested in finding the "hook" that would let me configure an alternate serializer (JSON.Net and not JavaScriptSerializer) for use by this incoming mapping scheme. There are many solutions to how to change the serializer for outgoing JSON (most of which create a custom JsonResult class for action methods to return). However, that doesn't address the need that I have.

WebAPI has a convenient GlobalConfiguration object available with lots of configuration points. You can just modify it in global.asax. Is there a similar mechanism available in ASP.NET MVC 4?

blaster
  • 8,876
  • 11
  • 48
  • 77
  • The Web API already use JSON.Net by default. Or am I missing your point? – cheesemacfly Oct 07 '13 at 18:47
  • Sorry, I'm asking about my ASP.NET MVC4 project (and just noting enviously that WebAPI projects make the same thing easy) . . . – blaster Oct 07 '13 at 19:35
  • 1
    @blaster was my extended answer here: http://stackoverflow.com/a/14591946/872395 not enough? See also this full ValueFormatter implementation: http://json.codeplex.com/discussions/347099 using JSON.NET – nemesv Oct 07 '13 at 19:37
  • Oh! Sorry about that; I had not yet seen your comment on the other question. I need to make sure I've caught up with all my notifications before posting. That looks like it will be just what I need. Thank you! – blaster Oct 07 '13 at 20:50

0 Answers0