Writing an image to ResponseBase.OutputStream does not work anymore with ASP.NET MVC2 RC2
- by labilbe
The following code worked nice on ASP.NET MVC1
public class ImageResult : ActionResult
{
public Image Image { get; set; }
public override void ExecuteResult(ControllerContext context)
{
if (Image == null)
{
return;
}
HttpResponseBase response = context.HttpContext.Response;
response.ContentType = "image/png";
Image.Save(response.OutputStream, ImageFormat.Png);
}
}
I spent some time searching answers but I didn't find anyone.
The error thrown is
OutputStream is not available when a custom TextWriter is used.