In web application, i am using code, to download the documnet which is uploaded, which is written in item command event of datalist, but it s giving error like “Thread was being aborted” can you help me to solve this, thank you. My code is as fallows.
protected void dtlstMagazine_ItemCommand(object source, DataListCommandEventArgs e)
{
try
{
objItMagBe.TitleId = Convert.ToInt32(e.CommandArgument);
dts = new DataSet();
dts = objItMagBL.GetMagzineByTitleID(objItMagBe);
GetPopularMagazine();
string Myfile = "../xxxx/DataFiles/" + dts.Tables[0].Rows[0]["Files"].ToString();
if (File.Exists(Server.MapPath(Myfile)) == true)
{
Response.AppendHeader("Content-Disposition", "attachment; filename=" + Myfile);
Response.TransmitFile(Server.MapPath(Myfile));
Response.End();
Response.Flush();
}
}
catch
{
}
}
Your Response.End() is most likely what is causing that. It is because it is telling ASP.NET that the request is over.
What is the stack trace from the Exception, where does .NET think the exception is being thrown from?