Trying to post an array of strings to controller
My controller
public ActionResult GetMessage(List<string> ancestry)
{
}
My javascript
var s = ["a", "b", "c"];
$.post(newareaurl, { s: JSON.stringify(s) }, function (data) {
});
But the controller receives the data as a List with single element containing "[\"a\",\"b\",\"c\"]", I'm expecting it could receive a List with three elements.
I have tried setting the traditional style param serialization using traditional: true but it gives me "[object Object]" value in the controller
$.ajax({
url: newareaurl,
type: 'POST',
data: { s: s },
traditional: true,
success: function (newTerritory) {
console.log(newTerritory);
},
error: function () {
}
});
How to properly post the array?