Search code examples
asp.netasp.net-mvc-5favicon

Favicon only shows in Homepage ASP.NET MVC


I just add this in the head of my _Layout.cshtml.

<head>  
    <link rel="shortcut icon" type="image/ico" href="~/Images/favicon.ico">
</head>` 

the icon is showing but only in homepage, what is the reason for that?


Solution

  • In general, it is a good practice to put all favicon-related files in the root directory of the web site. Some browsers will always check for favicon.ico in the root folder.

    <head>  
        <link rel="shortcut icon" type="image/ico" href="~/favicon.ico">
    </head>
    

    Also, take a look at these posts

    Is putting your favicon.ico file in a non-root path a bad idea?

    Serving favicon.ico in ASP.NET MVC