I'm using the following code to to download files, but I'm face that Response.End
always causes Exception
. Is This cost for my application behavior? if yes how can get an alternative way to download files. I tried to use Thread.ResetAbort()
to handle the exception but this result unwanted additional data to be added to the file
try
{
DownloadFiles();
Response.End();
}
catch (ThreadAbortException)
{
// Thread.ResetAbort();
}
catch (GSException ex)
{
Response.ClearHeaders();
hdnResult.Value = ex.Message;
// ClientScript.RegisterStartupScript(this.Page.GetType(), "checkDownloadError", "window.parent.checkDownloadError('" + ex.Message + "');", true);
}
catch (Exception)
{
Response.ClearHeaders();
hdnResult.Value = "Oops! Something unexpected happened. Please try again later";
//ClientScript.RegisterStartupScript(this.Page.GetType(), "checkDownloadError", "window.parent.checkDownloadError('Oops! Something unexpected happened. Please try again later');", true);
}