【发布时间】:2015-12-02 19:44:48
【问题描述】:
我需要创建一个调用通用处理程序 (ashx) 的 JS 方法 返回一个文件(字节数组)。该文件可以是 xml、txt 或 Pdf。 我使用下面的代码解决了我的问题,但是当文件不存在时, 我被重定向到另一个带有错误消息的页面(如果我在 ashx 中配置它,则为 404), 但我只想向用户显示错误消息。我该怎么做?
function GetFile(idAction, chave, fileType) {
window.downloadfile = function (e) {
window.location = "MyHandler.ashx?parameter1="
+ idAction + "¶meter2=" + fileType + "¶meter3=" + chave;
}
downloadfile();
}
【问题讨论】:
标签: javascript jquery .net ashx generic-handler