I need create a JS method that calls a Generic Handler (ashx) that returns a file (byte array). This file can be a xml, txt or Pdf. I resolve my problem using the code below, but when the file doesn't exists, I'm redirected to another page with error message (or 404 if I config it in ashx), but I want just show a alert message to user with the error. How can I do that?
function GetFile(idAction, chave, fileType) {
window.downloadfile = function (e) {
window.location = "MyHandler.ashx?parameter1="
+ idAction + "¶meter2=" + fileType + "¶meter3=" + chave;
}
downloadfile();
}