我正在使用以下代码下载文件,但我面对的是Response.End
总是导致Exception
. 这是我的应用程序行为的成本吗?如果是的话,如何获得另一种下载文件的方法。我试图用来Thread.ResetAbort()
处理异常,但这会导致不需要的额外数据被添加到文件中
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);
}