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?
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?