Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2006

Tip: Looking for answers? Try searching our database.

error "Thread Being Aborted" while downloading file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hitendra15@gmail.com - 15 Feb 2006 11:14 GMT
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
Thanks Hans Kesting

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.