I had the similar issue. The cause was that my MemoryStream was disposed prematurely. The exception was caught by my exception handling page which returns html content to client. It's been working fine after removing "using".