On the client side, I have an associative array where I store pairs of "Guid" - "int". I pass the array to the server using json:
$.ajax({
url: methodUrl,
type: 'POST',
async: false,
data: { values: items },
dataType: 'json',
success: function (data) {
}
});
The object I'm trying to transfer looks like this (taken from the Chrome debugger):
items: Object
44f871e0-daee-4e1b-94c3-76d633a87634: 1
698ce237-3e05-4f80-bb0d-de948c39cd96: 1
In the controller, I have a method
public ActionResult Method(Dictionary<Guid, int> values)
{
}
However, the property values remain zero. Having only the Guides list on the client side and List in the controller, everything works fine. I suspect that I should choose a different type for the values in the controller, and not in the dictionary. I also tried adding “traditional: true” to the ajax request, however without success.
Any advice is appreciated!
source
share