JQuery.FileDownload (https://github.com/johnculviner/jquery.fileDownload) plugin'ini düzgün çalıştırabilmek için Set-Cookie ve Cache-Control header larının code behind kısmında eklenmesi gerekiyor.
Download.aspx.vb
Response.Clear()
Dim timestamp As String =
Request.QueryString("timestamp")
timestamp = CodeHelper.CheckClientContent(timestamp)
Dim fileName As String = "File_" &
timestamp & ".xlsx"
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Response.AddHeader("Content-Disposition", "attachment;filename=" &
fileName)
Response.AddHeader("Set-Cookie",
"fileDownload=true; path=/")
Response.AddHeader("Cache-Control",
"no-cache, no-store, must-revalidate")
Using myMemoryStream As New MemoryStream
pck.SaveAs(myMemoryStream)
myMemoryStream.WriteTo(Response.OutputStream)
Response.Flush()
Response.End()
End Using
Javascript tarafı
$find("mpePleaseWait").show();
var timestamp = $.now();
$.fileDownload(encodeURI("Download.aspx?ExportType=PSM×tamp="
+ timestamp), {
successCallback: function (url) {
$find("mpePleaseWait").hide();
},
failCallback: function (responseHtml, url) {
$find("mpePleaseWait").hide();
}
});
No comments:
Post a Comment