title: Passing an int array to MVC Controller
body: <p>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.</p>
  
  <pre><code>var dataArray = getAllIds(); //passes back a JavaScript array 
  window.location.replace("/" + controllerName + "/EditAll?ids=" + dataArray + "&amp;currentID=" + dataArray[0])
  </code></pre>
  
  <p>dataArray contains 1,7 as expected for my sample usage.</p>
  
  <p>Controller Code</p>
  
  <pre><code>public virtual ActionResult EditAll(int[] ids, int currentID)
  {
  
    currentModel = GetID(currentID);
    currentVM = Activator.CreateInstance&lt;ViewModel&gt;();
    currentVM.DB = DB;
    currentVM.Model = currentModel;
    currentVM.ViewMode = ViewMode.EditAll;
    currentVM.ModelIDs = ids;
  
    if (currentModel == null)
    {
        return HttpNotFound();
    }
  
    return View("Edit", MasterName, currentVM);
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <pre><code>window.location.replace("/" + controllerName + "/EditAll?ids=" + JSON.stringify(dataArray) + "&amp;currentID=" + dataArray[0])
  </code></pre>
  
  <p>Again the id array ends up null on the controller side.</p>
  
  <p>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.</p>
  
  <p>Thanks!</p>