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

后端 未结 4 2097
面向向阳花
面向向阳花 2021-02-13 17:54

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.

<
相关标签:
4条回答
  • 2021-02-13 18:25

    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(/.*)?" });
    
    0 讨论(0)
  • 2021-02-13 18:30

    The browser asks for it to set as the icon for the page, next to the title (in titlebar, tab, bookmarkmenu).

    0 讨论(0)
  • 2021-02-13 18:33

    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.

    0 讨论(0)
  • 2021-02-13 18:36

    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.

    0 讨论(0)
提交回复
热议问题