Make JsonValueProviderFactory work with dictionary types in ASP.NET MVC - by Darin Dimitrov

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 636647 Comments
Status Closed Workarounds
Type Suggestion Repros 0
Opened 1/18/2011 7:45:44 AM
Access Restriction Public


The System.Web.Mvc.JsonValueProviderFactory introduced in ASP.NET MVC 3 enables action methods to send and receive JSON-formatted text and to model-bind the JSON text to parameters of action methods. Unfortunately it doesn't work with dictionaries. For example if we have the following model class:

public class MyViewModel
    public IDictionary<string, string> Countries { get; set; }

and the following controller action:

public ActionResult Index(MyViewModel model) 
    return Json(model);

when we send a JSON encoded request like so:

var data = {
    countries: {
        'a': 'country a',
        'b': 'country b',
        'c': 'country c'
    url: '@Url.Action("index")',
    type: 'post',
    contentType: 'application/json; charset=utf-8',
    data: JSON.stringify(data),
    success: function (result) {

the Countries property is not bound inside the Index action.
Sign in to post a comment.
Posted by Microsoft on 10/26/2012 at 5:04 PM
This has been fixed in MVC4 RTM.
Posted by chris-yang on 7/19/2012 at 2:19 AM
Seems still can not work with OrderedDictionary.
Posted by John Reilly on 11/24/2011 at 5:48 AM
Hi Guys,

Whereabouts did the fix need to be applied and when will it be shipped? We're using the workaround at the moment but we'd rather use the fix if that's possible?

I think Chris would quite like to know too!
Posted by chris.h on 8/26/2011 at 12:57 PM
This issue is closed as fixed. What version has the fix and has it been released?
Posted by Microsoft on 6/6/2011 at 2:01 PM
Thank you for taking the time to report this problem. We have fixed the problem in the code.

Jean-Sébastien Goupil
Posted by Microsoft on 1/18/2011 at 7:58 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(