473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

error "Thread Being Aborted" while downloading file

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

Feb 15 '06 #1
4 6038
DWS
try taking out the response.write("") out of the catch block.

"hi********@gmail.com" wrote:
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

Feb 15 '06 #2
> 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


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
Feb 15 '06 #3
Thanks DWS

Feb 15 '06 #4
Thanks Hans Kesting

Feb 15 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: vincent wehren | last post by:
Hi, Trying to grasp Py_NewInterpreter()in a simple app embedding Python, I was wondering why the following gives me an error: int main() { PyThreadState *tstate; Py_Initialize();
1
by: Elliot M. Rodriguez | last post by:
A few of our customers cannot access one of the pages on our vb.net asp.net site. The problems are limited to only a few people, but these people have the problem regularly. The page in question...
3
by: SKG | last post by:
I have a web page with customized datagrid and a usercontrol. Sometimes iam getting "operation aborted" internet explorer cannot find site <web page name..> when i click back button i see the page...
3
by: Stephen Miller | last post by:
I have an ASP.Net application that sends a NetworkStream to a .Net Service, which has a TcpListener listening on a port for the ASP.Net client. When it receives a request it creates a new thread...
3
by: Nice | last post by:
how to comprehend the "Thread Safety"?
5
by: Aleramo | last post by:
I hope someone could say me where can i find the meaning of: gsl: sinint.c:359: ERROR: domain error Default GSL error handler invoked. Aborted or where i can find it. I don't understand the...
1
by: -Lost | last post by:
This is more of a post to inform, unless of course I am missing something fundamental, in which case I would appreciate anyone explaining it. Based on Mr. Michaux's camelizeStyle function I...
1
by: rmgalante | last post by:
I was wondering if anyone knows whether MS has a fix for the Menu Control. If the page is loading while you mouse over a menu control with child menus that pop out, you can generate the following...
2
by: gert | last post by:
is there any way i can make setTimeout work with a private obj ? function() { var obj setTimeout("thread(obj)",0) }
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.