2

I have the following controller action:

   var fileName = "monthly_report.pdf"
    var document = new Document();
    //DO SOME STUFF WITH THE DOCUMENT

    MemoryStream stream = new MemoryStream();
    doc.Save(stream, SaveFormat.Pdf);
    byte[] bytes = stream.GetBuffer();
    Response.Clear();
    Response.ContentType = "application/pdf";
    Response.AddHeader("content-disposition", "attachment; filename="+fileName);
    Response.BinaryWrite(bytes);
    Response.End();

I want to call the above controller action with a parameter date so it returns me a pdf file that can be downloaded in the browser.

While it already is being returned in the response it displays lots of unreadable signs and i cannot get the file download to start doin it via an ajax call ( which i know now doesn work ).

The question is: how do i call a controller action from javascript with a javascript var as parameter with an action that is not an ajax call?

user1950859
  • 41
  • 1
  • 5

1 Answers1

0

Very simple !

Use :

window.open("http://url_of_your_pdf_built_in_function?vars=something&etc=something");

Regards

Sayris
  • 21
  • 3