I'm trying to pass an array of int from JavaScript to an MVC controller that accepts 2 parameters - an int array and an int. This is to perform a Page Redirect to the View returned by the Controller Action.
var dataArray = getAllIds(); //passes back a JavaScript array 
window.location.replace("/" + controllerName + "/EditAll?ids=" + dataArray + "¤tID=" + dataArray[0])
dataArray contains 1,7 as expected for my sample usage.
Controller Code
public virtual ActionResult EditAll(int[] ids, int currentID)
{
  currentModel = GetID(currentID);
  currentVM = Activator.CreateInstance<ViewModel>();
  currentVM.DB = DB;
  currentVM.Model = currentModel;
  currentVM.ViewMode = ViewMode.EditAll;
  currentVM.ModelIDs = ids;
  if (currentModel == null)
  {
      return HttpNotFound();
  }
  return View("Edit", MasterName, currentVM);
}
The issue is that when inspecting the int[] ids passed to the controller, it's value is null. currentID is set to 1 as expected.
I've tried setting jQuery.ajaxSettings.traditional = true which has no effect I've also tried creating a server side url using @Url.Action in JavaScript. I also tried JSON.Stringify before passing the array e.g.
window.location.replace("/" + controllerName + "/EditAll?ids=" + JSON.stringify(dataArray) + "¤tID=" + dataArray[0])
Again the id array ends up null on the controller side.
Does anyone have any pointers on getting the int array to pass to the controller correctly? I could declare the parameter as String in the Controller Action and manually serialize and de-serialize the parameter but I need to understand how to get the framework to automatically do simple type conversions.
Thanks!
