Sto richiedendo la pagina .ashx dalla pagina master script lato client (Jquery) che ha un codice per scaricare un file PDF. Quando eseguo il debug, posso vedere l'esecuzione del codice "download del file" ma il file non viene scaricato.download di file chiamando la pagina .ashx
$.ajax({
type: "POST",
url: "FileDownload.ashx",
dataType: "html",
success: function (data) { }
}
);
public class FileDownload : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
//context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
string fileName = "BUSProjectCard.pdf";
string filePath = context.Server.MapPath("~/Print/");
context.Response.Clear();
context.Response.ContentType = "application/pdf";
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
context.Response.TransmitFile(filePath + fileName);
context.Response.End();
}
questo post potrebbe aiutare? http://stackoverflow.com/questions/1999607/download-and-open-pdf-file-using-ajax –