You can also do this quite simply with a controller action:
public void RenderImage(int imageId)
{
byte[] data = this.repo.GetImageData(imageId);
if (data != null)
{
Response.ContentType = "image/jpeg";
Response.Expires = 0;
Response.Buffer = true;
Response.Clear();
Response.BinaryWrite(data);
}
else
{
this.ControllerContext.HttpContext.ApplicationInstance.CompleteRequest();
}
}
source
share