I am working on an asp.net mvc 3 application that has an Action Method for handling GET requests and returning a page. The code snippet is shown below:
[HttpGet]
public ActionResult Print(IEnumerable<string> arrayOfIds)
{
.......................
return View(someModel);
}
There is also JavaScript code that invokes this action:
window.open('@Url.Action("Print","Appointments")' + urlArray, "Print", "width=620,height=410,scrollbars=yes");
The issue arises when the urlArray becomes very large. Is there a way to pass this data to the Action Method without using a URL string (perhaps by utilizing the content of the HTTP Request)? This is necessary because the URL size is causing issues with browser handling.
UPDATE: In case my previous explanation was unclear... I have found a solution to my problem. Here is the updated JavaScript code:
$.ajax({
url: '@Url.Action("Print","Appointments")',
type: "POST",
data: { listOfIds : listOfIds },
dataType: "text",
traditional: true,
success: function (data) {
printWindow = window.open('', 'Print');
printWindow.document.write(data);
}
});
Additionally, I changed the attribute of the Action Method from HttpGet to HttpPost.