Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is Chrome searching for my favicon.ico when I serve up a file from ASP.NET MVC?
    primarykey
    data
    text
    <p>I have a controller in MVC serving up images from a database.</p> <p><b>EDIT:</b> This still happens if I serve up a file over completely standard means in MVC.</p> <p>Every time I request my image, Google Chrome also searches for my favicon.ico.</p> <p>To avoid unnecessary discussions about other things "I should also care about" let us assume I do not care for caching whatsoever in this example and I shall always return HTTP response 200 with the file.</p> <p>In my controller I return the following:</p> <pre><code>return File(fileBytes, contentType); </code></pre> <p>After inspecting Fiddler 2, the following response is generated:</p> <blockquote> <p>HTTP/1.1 200 OK<br/> Cache-Control: public<br/> Content-Type: image/gif<br/> ETag: oYu19wKo+KEHkyxZQ2WXAA==<br/> Server: Microsoft-IIS/7.0<br/> X-AspNetMvc-Version: 1.0<br/> X-AspNet-Version: 2.0.50727<br/> X-Powered-By: ASP.NET<br/> Date: Tue, 16 Jun 2009 18:48:45 GMT<br/> Content-Length: 29344<br/></p> </blockquote> <p>By comparison, this is the response in Fiddler from Google when I request (for the first time) the Google logo:</p> <blockquote> <p>HTTP/1.1 200 OK<br/> Content-Type: image/gif<br/> Last-Modified: Wed, 07 Jun 2006 19:42:34 GMT<br/> Date: Tue, 16 Jun 2009 18:50:54 GMT<br/> Expires: Wed, 16 Jun 2010 18:50:54 GMT<br/> Cache-Control: public, max-age=31536000<br/> Server: gws<br/> Content-Length: 8706<br/> Age: 2<br/></p> </blockquote> <p>However, in Chrome after getting my image Chrome attempts to find my favicon.ico. It does <em>not</em> try this after requesting the Google logo.</p> <p>Any ideas why this might be happening? From my understanding on HTML, the answer must be in the response header because surely that is all the client has to go on? Please correct me!</p> <p><b>EDIT 2:</b> It seems a lot of people have completely misunderstood the problem. <i>The problem is <b>not</b> the lack of a favicon and the erroring requests in MVC - it's the problem of requesting a favicon when only an image is being loaded, with a content type of "IMAGE/JPEG", as opposed to a webpage with a content type of "TEXT/HTML"!!</i></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload