에서 파일을 열 내가에서 .aspx 페이지와이를 통해 이동하여 파일을 다운로드 생각하는 것은 파일을다운로드 및 jQuery를
HttpContext.Current.Response.ContentType = "APPLICATION/OCTET-STREAM";
String Header = "Attachment; Filename=" + sFileName;
HttpContext.Current.Response.AppendHeader("Content-Disposition", Header);
FileInfo Dfile = new FileInfo(HttpContext.Current.Server.MapPath(sFilePath));
HttpContext.Current.Response.WriteFile(Dfile.FullName);
HttpContext.Current.Response.End();
을 반환하고 괜찮아요.
jQuery를 사용하여 async ajax 호출을 통해이 작업을 수행 할 수 있기 때문에 파일을 다운로드하는 동안 사용자가 GIF 회 전자 애니메이션을 볼 수 있습니다.
$("#showbusy").fadeIn();
$.ajax({ async : true, type: "GET", url: "download.aspx",
contentType: "application/text; charset=utf-8",
success: function (data) {
$("#showbusy").hide();
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
$("#showbusy").hide();
}
});
전에서 .aspx 페이지 파일 다운로드로 직접 이동,하지만 어떤 이유로이 페이지에 Ajax 호출을 수행하여 작동하지 않는 경우. Firebug에서 데이터가 반환되는 것을 볼 수 있지만 일단 다운로드가 완료되면 메모리에 저장됩니다.
파일 다운로드 데이터를받은 후 실제로 브라우저 측에서 파일 저장 대화 상자를 실행하려면 어떻게해야합니까?
나는 이것이 당신의 문제라고 생각한다. 해결책 : http://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download – karim79
HttpContext.Current.Response.TransmitFile ("filename"). AJAX 호출을 사용하는 대신 다운로드 링크를 숨겨진 iframe으로 이동하십시오. 이렇게하면 페이지를 새로 고치지 않고 다운로드 상자가 표시됩니다. –