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?