HttpResponse.WriteFile sends uncomplete file

  • Thread starter Thread starter lolo
  • Start date Start date
L

lolo

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
 
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.
 
In addition, you may consider using
HttpContext.Current.ApplicationInstance.CompleteRequest 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
 
GOOD! You gave me the solution.

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

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

Alfonso & Ivan
 
Back
Top