Skip to content

Instantly share code, notes, and snippets.

@paggiogriot
Created July 19, 2015 16:35
Show Gist options
  • Save paggiogriot/c9504226a6b157380909 to your computer and use it in GitHub Desktop.
Save paggiogriot/c9504226a6b157380909 to your computer and use it in GitHub Desktop.
Passing Javascript array to ASP.NET MVC Controller
You can try json.net library to solve your issue
[JsonFilter(Param = "attributes", JsonDataType = typeof(AttributeViewModel[]))]
public JsonResult Save(AttributeViewModel[] attributes)
At client:
$.ajax({
type: 'POST',
url: url,
async: true,
data: JSON.stringify(attributes), //!!! Here must be the same name as in controller method
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (data) {
},
error: function (xhr, ajaxOptions, thrownError) {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment