I am calling a file download action from javascript:
$elem.click(function() {
window.location.href = 'MyController/MyFileDownloadAction';
});
The controller returns a file:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult MyFileDownloadAction()
{
/* do some processing, generate an in-memory file... */
return File(myFileStream, "text/plain", myFileName);
}
This action has a pretty high likelyhood of throwing an exception (or at least not being able to return the file).
Due to the nature of the application (which contains a lot of dynamic content), I can't really redirect to an error page in this situation. The current page needs to stay open somehow.
So I'm ideally looking for something like a javascript pop-up, but afaik this isn't going to be possible since I don't know any way to return a javacript instruction in a non-ajaxed controller call. If I display an error page I need to force it to open in a new window some how. Is there any possible solution to this problem?