PDF 파일을 다운로드 할 수있는 코드가있는 마스터 페이지 클라이언트 측 스크립트 (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 –