116

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

Muleskinner
  • 14,150
  • 19
  • 58
  • 79
  • This happens for me, too, but only on my dev machine. Did you ever find an explanation? – BrianFinkel May 06 '11 at 02:18
  • Is there any way to change the MIME types in Cassini? It seems to ignore the `` settings in the `` section in the web.config. – travis Nov 21 '12 at 17:20
  • 1
    why can't I be the one with 78 upvotes for the same problem? always too late.... – Scott Selby Nov 27 '12 at 02:20
  • 2
    almost 2½ years late ;o) – Muleskinner Nov 27 '12 at 08:45
  • I just discovered you can hold the control key down and select Error, Debug and Warning only. This way your log isn't cluttered with mime type errors while you're debugging but you see everything else. Very handy. –  Aug 09 '13 at 16:48

6 Answers6

84

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.

Stefan Mohr
  • 2,170
  • 2
  • 23
  • 35
  • 11
    Using IIS Express, there is no MIME type warning on PNG images. It is basically standard IIS 7.5 in a more portable form (and standard IIS has no trouble serving up PNGs). I just spun up a new project, confirmed the warning in Cassini (the dev server), set it to IIS Express and confirmed the warning went away. – patridge May 26 '11 at 18:16
  • The weird thing that I have encountered is that I have created an MVC ASP.NET 4 application and it works fine loading the png files in Cassini. I upgraded an MVC ASP.NET 1 application up to 4 and I encounter this problem in Cassini with the same png files. Any ideas? – MattB Oct 03 '12 at 17:10
  • 1
    @MattB - I suggest comparing the config files (csproj and web.config) between your fresh MVC4 project and the upgraded one side-by-side in a text editor. My first guess is there's an assembly reference or similar that didn't get automatically upgraded. If it's more complicated than that you may want to open a new question and include more details. – Stefan Mohr Oct 03 '12 at 21:12
  • @StefanMohr Thank you for your response, Sorry for the late return. I did do a comparison of both and didn't run across anything that looked out of the ordinary. I even went so far as to make necessary changes to both the csproj and web.configs to make them identical to the newly created ASP.Net MVC 4 project, no such luck. Ultimately, I just created a new project and ported everything to the new project. – MattB Oct 15 '12 at 18:36
  • The website is hosted on Azure and I get this annoying error packing my console. – Shimmy Weitzhandler Aug 19 '13 at 03:53
4

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

AddType image/png cur
AddType image/svg+xml svg svgz
Waqar Alamgir
  • 9,828
  • 4
  • 30
  • 36
4

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

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
  • 3
    @JimG If you are the administrator of a web server, you'd probably find the answer on [the sister site for webmasters](http://webmasters.stackexchange.com/q/31547/1918) – Rowland Shaw Jul 02 '12 at 08:05
  • +1 This is the most descriptive and useful answer. No idea why it has been downvoted so much. – Sir Crispalot Jul 02 '13 at 13:06
  • @JimG. If you were the administrator, you'd say what webserver you were using, or ask on the site for [webmasters](http://webmasters.stackexchange.com) – Rowland Shaw Aug 05 '13 at 07:38
  • Agreed, the most useful answer. Didn't understand @JimG. downvote. – Anoyz Nov 30 '13 at 21:02
2

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>
Vishal Vaishya
  • 596
  • 3
  • 15
0

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

0

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