0
FileHelperEngine engine = new FileHelperEngine(typeof(OrderCsvRow));

var writer = new StreamWriter(Response.OutputStream);

engine.WriteStream(writer, someOrders);

When I output the orders as a string it comes out fine. when I use Response.OutputSteam as in the code snipped the response it truncated towards the end - always at the same place.

How do I fix this?

Ian Warburton
  • 15,170
  • 23
  • 107
  • 189
  • 1
    Not enough information. Make sure that the `Content-Length` header in the `Response.OutputStream` is correct, otherwise, you'll only read as many bytes as `Content-Length` specifies. Remember that `Content-Length` is a count of bytes in the response, not a count of characters (the two values may be different!). – fourpastmidnight Aug 30 '13 at 21:36
  • Not enough information is exactly what I thought. I will give your suggestion a go. – Ian Warburton Aug 31 '13 at 08:56

2 Answers2

0

Fixed...

engine.WriteStream(Response.Output, someOrders);
Ian Warburton
  • 15,170
  • 23
  • 107
  • 189
0

Had a similar issue here, so I'll put down the solution I found for anyone else who comes by and needs it.

Source: https://bytes.com/topic/asp-net/answers/484628-response-outputstream-truncates-xmltextwriter

After doing your write, make sure you also flush your stream writer before completing the request. Otherwise the missing data might end up being left behind and not actually appended to the OutputStream. :)

Sollace
  • 668
  • 8
  • 12