【发布时间】:2023-03-28 07:20:02
【问题描述】:
我正在尝试将 OutputCache 添加到具有 WebImage.Write() 响应的 MVC 操作,但只要我添加它(即使持续时间为 0),内容类型就会从 image/jpeg 更改为 text/ html,然后我将图像呈现为浏览器中的文本。
示例代码 - 如果 OutputCache 属性被删除,这将正常工作:
[OutputCache(Duration = 3000)]
public void GetImage(Guid id)
{
//Create WebImage from byte[] stored in DB
DbImage image = DbImageDAL.SelectSingle(e => e.DbImageId == id);
WebImage webimage = new WebImage(image.Data);
webImage.Write();
//Tried webImage.Write("JPEG"); but it makes not difference
}
【问题讨论】:
标签: c# asp.net-mvc-4 outputcache webimage