image is not rendering in navbar - blazor

sblb 1,231 Reputation points
2022-08-19T15:31:21.71+00:00

Hi, I tried to put the image in NavMenu.razor but it's not rendering;

<div class="top-row pl-4 navbar navbar-dark">  
      <img src="~/images/logo3.svg" width="180" height="50" >  
              
    <button class="navbar-toggler" @onclick="ToggleNavMenu">  
        <span class="navbar-toggler-icon"></span>  
    </button>  
</div>  

Have you any suggestions?
Thanks in advance

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

Accepted answer
  1. AgaveJoe 30,126 Reputation points
    2022-08-19T16:08:07.367+00:00

    Have you any suggestions?

    Basic troubleshooting? Open the browser's dev tools and look for a 404 error.

    If you placed the image in wwwroot/images the proper syntax is...

    <img src="/images/logo3.svg" width="180" height="50" >  
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2022-08-19T18:15:02.477+00:00

    As blazor is client based, instead of using ~ to denote the site root, the html base ref is set instead. So all links are relative to wwwroot

    https://www.w3schools.com/tags/tag_base.asp


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.