pass a collection to controller and retrieve the resulting pdf

i have a view in which the model is a collection like this:

@model IEnumerable<SolutionName.Models.Foobar>

i have used it in javascript like this:

var _oFoobars =@Html.Raw( new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(Model));

the ActionResult that loads this view does not load any data. the view is initially blank. _oFoobars is refreshed from database, depending on user input. this object array is then sent to the controller to make a pdf file. but i am unable to retrieve the pdf file.

i have tried posting _oFoobars using Ajax, the resulting pdf file data from controller is not recognized. i have tried using a form, but since the model has no data, a null object is posted on submit button click.

is there any way i can post the object array to the controller and show the resulting pdf in a window?

Source: ajax

Leave a Reply