Response.OutputStream truncates XmlTextWriter?

R

richardtallent

(ASP.NET 2.0. Issue presents both on my copy of IIS on my workstation
(XP Pro) and my production server (Win2k3). I don't use any proxy
servers, anti-spyware apps, etc. Problem occurs using IE6SP2 and
Firefox 1.5.02.)

I'm writing large, sever-generated XML files to the browser.

This method works:

Dim xmltxt As New System.IO.StringWriter
Dim xml As New XmlTextWriter(xmltxt)
' xml.WriteStartDocument, etc....
Response.Write(xmltxt.ToString)

This, however, truncates the response a few KB shy:

Dim xml As New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
' xml.WriteStartDocument, etc....
Response.Flush()

I've also tried with Response.Buffer=False, to no avail. At first I
didn't have the Flush() call, added it just in case, but it's not
helping either.

The length of the generated document doesn't seem to matter. A 40KB
document is truncated, as is a 600KB. The amount of trunctation *may*
be proportionate to the full document size, but I haven't found the
pattern.

I would just give up and use what works, but my usual documents are
MUCH larger than 600KB, more on the order of 30-50MB, so I'm running
into memory issues buffering in StringWriter and I need to dump it to
the browser as it is generated.

Cheers,

--Richard
 
R

richardtallent

Doh!

Flushing the Response wasn't the issue, flushing the XmlTextWriter was.
Added:

- Response.Flush()
+ xml.Flush()

Works fine now...

--Richard
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top