मैं मास्टर पेज क्लाइंट साइड स्क्रिप्ट (Jquery) से .ashx पेज का अनुरोध कर रहा हूं जिसमें एक पीडीएफ फाइल डाउनलोड करने के लिए एक कोड है। जब मैं इसे डीबग करता हूं, तो मैं "फ़ाइल डाउनलोड" कोड का निष्पादन देख सकता हूं लेकिन फ़ाइल डाउनलोड नहीं हो रही है।फ़ाइल डाउनलोड करके .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();
}
यह पोस्ट मदद कर सकता है? http://stackoverflow.com/questions/1999607/download-and-open-pdf-file-using-ajax –