Response.End()
generates ThreadAbortException
.
Using HttpContext.Current.ApplicationInstance.CompleteRequest
in place of it d
Use the condition before download the file Response.IsClientConnected
-
if (Response.IsClientConnected)
{
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.TransmitFile(Server.MapPath(@"yourpath" + fileName));
Response.Flush();
Response.Close();
}
It's working for me well after lot of struggle. I hope it works for you too.