473,378 Members | 1,451 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,378 software developers and data experts.

HttpResponse.WriteFile sends uncomplete file

Hello everybody,

We have a problem sending a file to the browser from our aspx.
The problem is that the file received is uncomplete.
The browser shows the first characters of the file.
No exception or any kind of error is shown on server nor or browser.
It works properly locally, but it fails remotely almost always.

Can you help us?

The code is the following:

Response.ContentType = "text/xml";
Response.AddHeader( "content-disposition","inline; filename=dicom.xml");
Response.WriteFile("file.xml");
Response.Flush();
Response.Close();

Running on C#, VS 2003, w2k Pro (same results on win XP Pro), IIS 5.0

Thanks very much for your attention,

Alfonso & Ivan
Nov 16 '05 #1
3 6308
The documentation for Response.Close() says that this method closes the
connection. You don't want to close the connection until all the data has
been sent. Try using Response.End() instead.

"lolo" <pe********@gmail.com> wrote in message
news:be**************************@posting.google.c om...
Hello everybody,

We have a problem sending a file to the browser from our aspx.
The problem is that the file received is uncomplete.
The browser shows the first characters of the file.
No exception or any kind of error is shown on server nor or browser.
It works properly locally, but it fails remotely almost always.

Can you help us?

The code is the following:

Response.ContentType = "text/xml";
Response.AddHeader( "content-disposition","inline; filename=dicom.xml");
Response.WriteFile("file.xml");
Response.Flush();
Response.Close();

Running on C#, VS 2003, w2k Pro (same results on win XP Pro), IIS 5.0

Thanks very much for your attention,

Alfonso & Ivan

Nov 16 '05 #2
In addition, you may consider using
HttpContext.Current.ApplicationInstance.CompleteRe quest as an alternative
since response.end induces a thread abort exception.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------
"jeff" <ms**********@xoxy.net> wrote in message
news:es**************@TK2MSFTNGP10.phx.gbl...
The documentation for Response.Close() says that this method closes the
connection. You don't want to close the connection until all the data has
been sent. Try using Response.End() instead.

"lolo" <pe********@gmail.com> wrote in message
news:be**************************@posting.google.c om...
Hello everybody,

We have a problem sending a file to the browser from our aspx.
The problem is that the file received is uncomplete.
The browser shows the first characters of the file.
No exception or any kind of error is shown on server nor or browser.
It works properly locally, but it fails remotely almost always.

Can you help us?

The code is the following:

Response.ContentType = "text/xml";
Response.AddHeader( "content-disposition","inline;
filename=dicom.xml");
Response.WriteFile("file.xml");
Response.Flush();
Response.Close();

Running on C#, VS 2003, w2k Pro (same results on win XP Pro), IIS 5.0

Thanks very much for your attention,

Alfonso & Ivan


Nov 16 '05 #3
GOOD! You gave me the solution.

Well, calling End() was giving failed, giving the same result.

But HttpContext.Current.ApplicationInstance.CompleteRe quest did work.
Thanks very much for your help!

Alfonso & Ivan
Nov 16 '05 #4

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

Similar topics

0
by: Matthew Trunnell | last post by:
Hi everyone, I'm implementing the HTTP 206 Partial Content spec. This requires an additional header of the form: "Content-Range: xxx-yyy/zzz" See http://www.w3.org/Protocols/rfc2616/rfc2616-...
5
by: Tim Greenfield | last post by:
Hi, I have a problem I'm hoping is not too unusual. I'm trying to push a large file (50MB) out to the client from an ASP page. The reason I'm using an ASP page is so I can start the reading at a...
8
by: Scott C. Reynolds | last post by:
I want to serve a PDF right to a web page (cannot link browser directly to PDF file). Stumbled across Response.WriteFile this morning. On my machine (XP Pro) this worked fine: private void...
1
by: webbertsolutions | last post by:
I have an ASP.NET page that does Response.AppendHeader(HeaderName, HeaderValue); Response.ContentType = MimeType; Response.BufferOutput = false; Response.WriteFile(file); Response.Flush(); ...
11
by: Random | last post by:
I have tried all the Response methods I can think of (WriteFile, BinaryWrite, OutputStream) to write the byte array of a pdf file to the response. The result looks like it's trying, it comes up as...
2
by: LP | last post by:
Hi, I have a reporting application that exports data to different format and sends file to the browsers with the following code: string fileName = @"" + Request.QueryString; //fileName =...
3
by: Buddy Ackerman | last post by:
I'm trying to write files directly to the client so that it forces the client to open the Save As dialog box rather than display the file. On some occasions the files are very large (100MB+). On...
5
by: Daniel Corbett | last post by:
I am trying to save a file dynamically created in a webpage. I get the following headers, but cannot figure out how to save the attachment. I am basically trying to replicate what internet...
2
by: Vadim | last post by:
Hi, I will have to send a file to a user's browser to be opened in a Save, Open manner, I am using HttpResponse.WriteFile for this, the info to be sent will have to be first accumulated in a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.