I'm trying to build up a string array in JavaScript and get the results in a string list in the action method. Below is what my JavaScript looks like. I'm using jQuery 1.4.2. The problem is my List in the action method is always showing NULL. Will a JavaScript string array not map correct to a string list in C#?
var test = ['test1', 'test2'];
var parms = {
var1: 'some string',
var2: test
};
$.ajax({
type: "POST",
url: "/Test/JSONTestAction",
async: false,
data: parms,
dataType: "json",
success: function(data) {
// success
}
});
Then my JsonResult looks like the following:
public JsonResult JSONTestAction(string var1, List<string> var2)
{
// var2 is always NULL -- not good
return Json(new { test = "test" });
}