Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net Mvc: why is browser looking for favicon.ico

I know there is a solution to stop the mvc framework to process "favicon.ico" requests (solution), but i don't know why is it looking for this icon in the first place.

I searched using Find in Files > Entire Solution for favicon.ico and nothing was found.

I searched in the html source code of the website for favicon.ico and nothing was found.

Where is it? why the browser is trying to serve it?

like image 517
Catalin Avatar asked Oct 29 '13 08:10

Catalin


3 Answers

favicon.ico is a convention - but is one way that the browser can get the image for links, tabs, etc:

enter image description here

Note that these days, the image location can also be set in metadata (which is handy as it allows the image to be per-page rather than per-domain, and/or allows for serving it from a different location, such as a CDN):

<link rel="shortcut icon" href="//cdn.sstatic.net/stackoverflow/img/favicon.ico">
<link rel="apple-touch-icon image_src" href="//cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png">

However, "/favicon.ico" is the fallback, and is used by many old browsers - or where no explicit shortcut icon is specified.

Basically: go create one.

like image 91
Marc Gravell Avatar answered Nov 02 '22 03:11

Marc Gravell


You better have one since it is standard to most browsers to look for the favicon.ico however if you really don't want to have it and get rid of the error just add this line in your RegisterRoutes class.

routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });
like image 25
Jobert Enamno Avatar answered Nov 02 '22 03:11

Jobert Enamno


Some browsers just look for favicon.ico in the root of your website by default.
I think the easiest way to stop the browser looking for this file is provide the image once, then the browser will cache it and stop asking.

like image 1
Buh Buh Avatar answered Nov 02 '22 05:11

Buh Buh