Problem with adding favicon to blazor server

Saeed Pooladzadeh 241 Reputation points
2023-04-26T07:21:29.5566667+00:00

Hello, I want to insert a link for the site favicon in the layout. C HTML, my link is:

<link rel="icon" type="image/x-icon" href="wwwroot/favicon.ico">

but I get this error: Untitled1

But as you can see my favicon is in the wwwroot folder: Untitled2

Do you think what is wrong? regards, Saeed

Developer technologies ASP.NET ASP.NET Core
Developer technologies .NET Blazor
0 comments No comments
{count} votes

Accepted answer
  1. Xinran Shen - MSFT 2,091 Reputation points
    2023-04-26T08:09:07.8566667+00:00

    Hi @Saeed Pooladzadeh

    From your error message, The project will find the favicon.ico in the path of ...\wwwroot\wwwroot\favicon.ico , But your favicon.ico just under the wwwroot folder, So you need to change your code like:

    <link rel="icon" type="image/x-icon" href="/favicon.ico">

    href will default find file under wwwroot folder, you don't need to add wwwroot in the path manually.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Xinran Shen

    2 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Timo Kinnunen 126 Reputation points
    2023-05-29T18:20:30.7566667+00:00
    Blazor web app
    
    create a my-logo.svg-file from your my-logo.png-file (1000 pixels x 1000 pixels or less)
    
    copy it here:
    <head>
    ...
    	<link rel="icon" href="images/my-logo.svg">
    </head>
    
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.