Why are you doing all that work with
ms
,
textWriter
and
bytesInStream
, what did you want to accomplish with that?
If you want to convert your
s
stream to memory stream then just use
s.CopyTo(ms);
and
ms.Position = 0;
.
But before that, I'm not exactly sure what is the resulting type of
out s
in
CreateReport
, but nevertheless why don't you just try the following:
if (s != null)
{
return new FileStreamResult(s, "application/pdf");
}
Or this:
if (s != null)
{
if (s.CanSeek)
s.Seek(0, SeekOrigin.Begin);
return new FileStreamResult(s, "application/pdf");
}