Setting ASP.NET Core 2.0 favicon

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

If your favicon.ico file is in wwwroot folder and if you are still getting 404 error when browser try to get favicon.ico, make sure you have app.UseStaticFiles(); in your Startup.cs -> public void Configure(IApplicationBuilder app, IHostingEnvironment env).

Please read Static files in ASP.NET Core for detail.

If you add favicon.ico in wwwroot and not in any subfolder, you don't need to add the <link ... tag in your html or cshtml.


In _Layout.cshtml include,

<link rel="shortcut icon" href="//.../content/images/favicon.ico" />