Chrome 中针对 png 图像的 MIME 类型警告
刚刚在 Chrome 中运行我的网站,令人惊讶的是,它对我的每个 .png 图像都出现了这个警告:
Resource interpreted as image but transferred with MIME type application/octet-stream.
有人以前见过这个吗?
问候
Just ran my site in chrome and suprisingly it comes up with this warning for each of my .png images:
Resource interpreted as image but transferred with MIME type application/octet-stream.
Anyone seen this before?
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我在使用 ASP.NET 开发服务器运行 ASP.NET WebForms 应用程序时遇到了这种情况。
我怀疑如果您也使用 IIS Express 作为服务器(VS 2010 SP1),也会发生类似的情况。
我通过编辑项目设置(在 Web 下)在本地“解决”了我的问题,并将本地计算机上的 ASP.NET 开发服务器更改为 IIS。我可以看到 PNG 已经被正确定义为图像 MIME 类型,事实上,当我访问本地 IIS 服务器时,它会提供正确类型的文件。
I encountered this while running an ASP.NET WebForms app using the ASP.NET Development Server.
I suspect something similar will happen if you use IIS Express as your server as well (VS 2010 SP1).
I 'resolved' my problem locally by editing the project settings (under Web) and changed from the ASP.NET Development Server to IIS on my local machine. I can see that PNG was already defined correctly as an image MIME type and indeed when I hit my local IIS server it's serving up the file with the correct type.
此警告告诉您,您的 Web 服务器未配置为发送 PNG 图像的正确 MIME 类型元数据。您可能应该咨询您的 Web 服务器管理员并要求他们设置正确的 MIME 映射
This warning is telling you that your web server isn't configured to send the correct MIME type meta data for PNG images. You should probably consult the administrator for your web server and ask them to set the correct MIME mapping
我在 .htaccess 中添加了这样的类型(AddType 图像/类型扩展)
IE
I added types like this in .htaccess (AddType image/type extention)
i.e.
当然以上解决方案是完美的。只是为了避免警告和干净的控制台,我在代码中进行了更改。 (这也仅适用于 ASP.NET 开发服务器)我为此编写了一个额外的处理程序:
PNGHandler.cs
并在 system.web 下的 web.config 中添加了 Http 处理程序
Ofcourse above solutions are perfect. Just to avoid warnings and for a clean console I done following change in my code. (that too only for ASP.NET Development Server) I written a extra handler for this:
PNGHandler.cs
And added Http Handler in web.config under system.web
我发现的解决垃圾邮件的最快方法是使用 CTRL 键选择“错误”、“警告”和“调试”,而不是全部选择。
全部:
错误、警告和调试:
The quickest way around the spam that I've found is to use the CTRL key to select Errors, Warnings and Debug instead of all.
All:
Errors, Warnings and Debug:
我通过在控制面板中启用静态内容解决了这个问题程序和功能 > 打开或关闭 Windows 功能 > IIS组件> 万维网服务 > 常见 HTTP 功能
I've solved this problem by enabling Static Content in Control Panel > Programs and Features > Turn Windows features on or off > IIS components > World Wide Web Services > Common HTTP Features