I wrote an Httphandler in asp.net that is responsible for returning a file. Within the code, I have implemented
Response.AddHeader("Content-Disposition", "attachment; filename=somefile.ext");
to ensure that the page URL remains unchanged.
However, when an error occurs within the Httphandler, the URL transforms into something like http://localhost:55161/document.axd
and I am left with a blank screen.
I am seeking a way to return a JavaScript alert from the Httphandler without triggering a page refresh. Is there a way to achieve this?
public class Document: IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
//Response.AddHeader("Content-Disposition", "attachment; filename=somefile.ext");
Response.ContentType = "application/javascript";
Response.Write("<script type ='text/javascript'>alert('Error!');</script>");
}
public bool IsReusable
{
get { return false; }
}
}
Apologies for any language barriers, English is not my native tongue :)