MIME type warning in chrome for png images

ImagePngGoogle ChromeMimeWarnings

Image Problem Overview


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

Image Solutions


Solution 1 - Image

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.

Solution 2 - Image

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

Solution 3 - Image

I added types like this in .htaccess (AddType image/type extention) i.e.

AddType image/png cur
AddType image/svg+xml svg svgz

Solution 4 - Image

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

class PNGHandler : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    { 
       if(context.Request.HttpMethod == "GET") 
       {
             string requestedFile = context.Server.MapPath(context.Request.FilePath);
             FileInfo fileinfo = new FileInfo(requestedFile);
             string contentType = "";
             if (fileinfo.Exists && fileinfo.Extension.Remove(0, 1).ToUpper() == "PNG")
             {
                   contentType = "image/png";
                   context.Response.ContentType = contentType;
                   context.Response.TransmitFile(requestedFile);
                   context.Response.End();
              }
         }
    }
}

And added Http Handler in web.config under system.web

<system.web>
 <httpHandlers>
 <add path="*.png" verb="*" type="PNGHandler" />
 </httpHandlers>
</system.web>

Solution 5 - Image

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: enter image description here

Errors, Warnings and Debug: enter image description here

Solution 6 - Image

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMuleskinnerView Question on Stackoverflow
Solution 1 - ImageStefan MohrView Answer on Stackoverflow
Solution 2 - ImageRowland ShawView Answer on Stackoverflow
Solution 3 - ImageWaqar AlamgirView Answer on Stackoverflow
Solution 4 - ImageVishal VaishyaView Answer on Stackoverflow
Solution 5 - ImageTHE JOATMONView Answer on Stackoverflow
Solution 6 - ImagebiglazypandaView Answer on Stackoverflow