相关疑难解决方法(0)

MVC WebImage OutputCache导致text/html的内容类型

我正在尝试将一个OutputCache添加到具有WebImage.Write()响应的MVC Action,但是一旦我添加它(即使持续时间为0),内容类型也会从image/jpeg更改为text/html和I获取在浏览器中以文本形式呈现的图像.

示例代码 - 如果删除了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
}
Run Code Online (Sandbox Code Playgroud)

c# outputcache asp.net-mvc-4 webimage

2
推荐指数
1
解决办法
993
查看次数

标签 统计

asp.net-mvc-4 ×1

c# ×1

outputcache ×1

webimage ×1