我正在使用MemoryStream在站点外渲染某些图像。像\ renderProductprice.aspx?Pid = xxx。这将返回带有Stream和ContentType的FileStreamResult。
private ActionResult GetPriceImage()
{
Image img = new Bitmap(100, 50);
Graphics g = Graphics.FromImage(img);
Font font = new Font("Arial", 24);
PointF drawingPoint = new PointF(10, 10);
g.DrawString("$Test Price", font, Brushes.Black, drawingPoint);
MemoryStream ms = new MemoryStream();
img.Save(ms, ImageFormat.Jpeg);
ms.Position = 0;
return new FileStreamResult(ms, "image/jpeg");
}
这在除chrome(任何版本)之外的所有浏览器中均可正常显示。