I have a HttpHandler returning an image through Response.OutputStream
. I have the following code:
_imageProvider.GetImage().CopyTo(context.Response.OutputStream);
GetImage()
method returns a Stream
which is actually a MemoryStream
instance and it is returning 0 bytes to the browser. If i change GetImage()
method signature to return a MemoryStream
and use the following line of code:
_imageProvider.GetImage().WriteTo(context.Response.OutputStream);
It works and the browser gets an image. So what is the difference between WriteTo and CopyTo in MemoryStream class, and what is the recommended way to make this works using Stream
class in GetImage()
method signature.