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

richinator38

我有一个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服务器上定义。

richinator38

我认为问题与无存储缓存控制标头有关。请参阅此链接以获取更多信息: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文件不存储时,我们将其更改为public或private。然后,我可以另存为jpg。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章