我正在从主页客户端脚本(
Jquery)请求.ashx页面,该脚本具有下载PDF文件的代码.当我调试它时,我可以看到执行“文件下载”代码,但文件没有下载.
$.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(); }