I'm trying to add and set a favicon for my ASP.NET Core project.
When I set up an initial project that Visual Studio 2017 creates automatically, the favicon.ico
file is just in the wwwroot
directory and there is no setting for it.
So, I add favicon file into wwwroot
directory, but the favicon does not show up in any browsers.
How can I set the favicon in ASP.NET Core so that it shows up?
wwwroot/index.html file has the link to favicon.
<link rel="icon" type="image/x-icon" href="favicon.ico">
is the code to add favicon to the website.
For .net core Single Page Application (SPA) project the favicon will be rendered from its own respective static file. For example if are using angular as client application there is index.html
file inside src
and in index.html
you can link your favicon with following code
<link rel="icon" type="image/x-icon" href="favicon.ico">
Similarly, to set favicon in MVC project, you need to edit layout template which is normally inside View > Shared > _Layout.cshtml
. You need to add <link rel="icon" type="image/x-icon" href="favicon.ico">
inside <head></head>
tag. If you are using multiple layout then you need to edit other files as well.