I have a controller method which returns response to download. It is working fine but when there is an exception occurs a blank page returned on the current page, where download is requested.
Also I am sending some form data to request the download.
Instead I need to show the error message as popup. How could I do that?
MVC Controller Method to download pdf. Its return pdf to download but sometimes when exception occurs it return a blank page.
[HttpPost]
public void Downloadpdf()
{
try
{
// Generate pdf
Response.Clear();
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Content-Disposition", "attachment;filename=Newpdf.pdf");
byte[] pdf = ms.ToArray();
Response.OutputStream.Write(pdf, 0, pdf.Length);
Response.End();
}
catch (Exception ex)
{
Response.End();
}
}
How should I show popup for the exception. And avoid blank page. Also it is a Single Page Application.