HttpResponse.WriteFile sends uncomplete file

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
 
J

jeff

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.
 
A

Alvin Bruney [MVP]

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
 
L

lolo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top