我正在使用ASP.NET MVC 5开发REST服务..这是一个简化的代码:
[HttpGet]
[Route("api/v1/qrcode")]
[OutputCache(NoStore = true, Location = OutputCacheLocation.None)]
public FileContentResult GenerateNewQrCode(int height = 200, int width = 200)
{
byte[] qrcode = ... some qrcode generation logic here ...
return new FileContentResult(qrCode.ToArray(), "image/gif");
}
您可以在此处试用:http://13.76.95.11:81/api/v1/qrcode
但谷歌浏览器会在控制台中显示Resource interpreted as Document but transferred with MIME type image/gif
...
可能是什么问题?
答案 0 :(得分:0)
没关系......只有当我直接在地址栏中输入图片网址时,才会显示此警告...
如果通过<img src="....
属性引用图片网址,则不会显示任何警告(无论如何这都是预期用途)。
因此,我猜Chrome会假设我们在网址栏中输入的内容属于Document
类型,但会接收图片。