Hi following is the code which sends file to the browser means user can
download file,
but the code generates error message Thread Being Aborted., will any
one put their thoughts
protected void SendFileToBrowser(string strpath)
{
try
{
FileInfo objFileInfo = new FileInfo(strpath);
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;
filename=" + objFileInfo.Name);
Response.AddHeader("Content-Length",
objFileInfo.Length.ToString());
Response.WriteFile(objFileInfo.FullName);
Response.End();
}
catch (Exception ex)
{
Response.Write("");
}
}
Thanks
----
Hitendra Patel
DWS - 15 Feb 2006 13:41 GMT
try taking out the response.write("") out of the catch block.
> Hi following is the code which sends file to the browser means user can
> download file,
[quoted text clipped - 24 lines]
> ----
> Hitendra Patel
Hiten - 15 Feb 2006 14:25 GMT
Hans Kesting - 15 Feb 2006 13:44 GMT
> Hi following is the code which sends file to the browser means user can
> download file,
[quoted text clipped - 24 lines]
> ----
> Hitendra Patel
You will get a "tread aborted" exception when you do a
Response.Redirect from within a try block. Maybe this also happens for
a Response.End.
Try moving that outside of the try/catch.
Hans Kesting
Hiten - 15 Feb 2006 14:26 GMT