I'm assuming that since you did not provide route values in Url.Action(...), the data you'd like to post to the action is being set by the user on the client?
If so, one very simple way to do it is have a form with hidden fields (or perhaps visible if you want direct user interaction) and then set those fields on Sort, and then submit the form.
For example:
<form id='sortform' action='@Url.Action("ActionName")' method='POST'>
<input type='hidden' name='MyFirstSortValue'>
<input type='hidden' name='MySecondSortValue'>
</form>
And:
function Sort() {
var formElem = document.getElementById('sortform');
formElem.MyFirstSortValue.value = "blah";
formElem.MySecondSortValue.value = "blah";
formElem.submit();
}
If you are just having the user select sort information, then I suggest having the form inputs visible and use them directly, rather than setting them indirectly when Sort is called.
Once the above is done, you can access the information via the controller using FormCollection . For example:
[HttpPost]
public ActionResult ActionName(FormCollection form)
{
string myFirstSortValue = form["MyFirstSortValue"];
string mySecondSortValue = form["MySecondSortValue"];
// Do something to sort the data in the model...
return View(yourModel);
}
This will cause the post back to occur with the data being transferred, and the desired view to be displayed.