我使用此代碼來下載文件,但它會引發錯誤。請幫我處理它。爲什麼我的代碼拋出線程中止錯誤?
線程正在中止。
protected void Download_Click(object sender, EventArgs e)
{
try
{
string filePath = Convert.ToString(Attachment);
string fullFilePath = ("../../SiteImages/" + "donald.jpg");
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + Path.GetFileName(fullFilePath) + "\"");
Response.ContentType = ContentType;
Response.TransmitFile(fullFilePath);
//MngLogs.InsertAuditsInfo("Tender downloaded via" + " " + MngLogs.PageName, MngLogs.UserMacAddress, MngLogs.UserIPAddress, UserID, "Download");
//Response.End();
}
catch (Exception ex)
{
Utility.Msg_Error(Master, ex.Message);
}
}
你從哪裏得到錯誤? 'Reponse.End()'總是拋出一個'ThreadAbortException'。看看[這個](http://stackoverflow.com/questions/20988445/how-to-avoid-response-end-thread-was-being-aborted-exception-during-the-exce)和[this] (http://stackoverflow.com/questions/5834049/what-causes-thread-was-being-aborted-exception-to-happen-at-random-and-show-th)後。 –
是相同的地方,我刪除它,但它仍然沒有下載文件 – Cuckoo
並不拋出錯誤,但仍然不下載文件 – Cuckoo