FileContentResult以jpg格式返回,但IE“将图片另存为”仅提供png或bmp

时间:2014-03-07 19:14:46

标签: internet-explorer asp.net-mvc-4

我有一个MVC 4控制器方法返回FileContentResult,如下所示:

[OutputCache(CacheProfile = "ImageCache")]
public FileContentResult GetImage(string dl)
{
    return File(photoSig.BinaryPhoto, "image/jpeg", "photo.jpg");
}

ImageCache定义如下:
<caching> <outputCacheSettings> <outputCacheProfiles> <add name="ImageCache" duration="1" varyByParam="*" location="Server" enabled="true" /> </outputCacheProfiles> </outputCacheSettings> </caching>

一切正常,除非在IE中,当用户将图片另存为...时,它只为他们提供了保存为PNG或BMP的选项。为什么不通过jpg? Chrome和FF提供了jpg选项。

另一个有趣的一点是它在我的本地盒子上工作正常,但在部署时却没有...这让我觉得它可能是一个配置问题。但我不知道从哪里开始寻找。 jpg的IIS MIME类型在UI服务器上定义。

1 个答案:

答案 0 :(得分:1)

我认为这个问题与no-store缓存控制头有关。有关详细信息,请参阅此链接:http://social.technet.microsoft.com/Forums/windows/en-US/e1f5c13b-92f0-4aa7-83b5-344edbe4093d/save-picture-as-jpeg-problem-ie7win-xp-pro-sp3?forum=itproxpsp

我们最终添加了一个IIS重写规则来解决问题......所以当它说jpg文件没有存储时,我们将其改为公共或私有。然后我可以保存为jpg。

相关问题