在我的页面中,我正在尝试下载文件。该文件下载成功,但我得到System.Threading.ThreadAbortException。所以我在我的尝试Catch Block中处理了这个错误,并将错误标签设置为空白,但它不会在页面中更新。标签在System.Threading.ThreadAbortException中未更新
catch (System.Threading.ThreadAbortException)
{
lblErrorMsg.Text = "dfdf";
}
catch (Exception ex)
{
lblErrorMsg.Text = "Error while processing you request :<br> Erorr Description : " + ex.Message;
}
这是我写文件功能
public static void WriteFile(string nameOfFile, string fileContent, HttpResponse writer)
{
writer.ClearHeaders();
writer.ClearContent();
writer.ContentType = "text/xml";
writer.AppendHeader("Content-Disposition", "attachment; filename=" + nameOfFile);
writer.Write(fileContent);
writer.Flush();
writer.End();
}
谁能告诉为什么即使谈到system.thread.threadabortexceptiopn的catch块下,当我调试的代码标签没有被设置为空白?
我没有在标签上写任何内容。只需在标签上写入例外。在你的答案中的链接不帮助我:(你能给我具体的解决方案 – Happy
也正如你可以在我的代码中看到,我没有做response.redirect – Happy
第一个问题:你明确地清空响应内容来取代你的下载,第二个问题:你有没有在第二个链接上看到user3412640的回答?我告诉过你,问题在于对End()的调用,你的回应的方法 – AFract