I have the following code that i am using to run a controller action on my asp.net-mvc site:
asp.net-mvc Controller Action:
public ActionResult MyAction(PostParams myParams)
{
//go do stuff
}
where PostParams is defined as:
public class PostParams
{
public int Age {get;set;}
public string Name {get;set;}
}
Javascript Code:
$("#myButton").live('click', function (e) {
window.location.href = "/MyController/MyAction?Age=10&Name=Joe";
});
NOTE: Before someone responds with "You should be using Ajax", I am unable to use ajax here because my controller action is returning a file as per this question here.
I now need to pass in some additional data which is the result of a jquery UI sortable list like this which comes in as json. so that looks like this:
$("#myButton").live('click', function (e) {
var sortables = $(".sortableList");
var arr = [];
sortables.each(function () {
var statusParam = new Object();
statusParam.Ids = $(this).sortable("toArray");
arr.push(statusParam);
});
var myResult = JSON.stringify({ result: arr });
window.location.href = "/MyController/MyAction?Age=10&Name=Joe";
});
My question is, what is the correct way to include the "myResult" into the query string where it will show up on the server side correctly. I have tried this:
var myResult = JSON.stringify({ result: arr });
window.location.href = "/MyController/MyAction?" + myResult + "&Age=10&Name=Joe";
});
and included a new field in the PostParams like this:
public class PostParams
{
public List<MyItem> result {get;set;}
public int Age {get;set;}
public string Name {get;set;}
}
public class MyItem
{
public List<int> Ids { get; set; }
}
but result always seems to be null when I check it on the server side.

myResultin the debugger? You may be missing an&