Showing image

Frank Mehlhop 66 Reputation points
2022-07-29T07:00:36.403+00:00

A image in my Blazor site is not shown.

In NavMenu.razor I implement:

<img href="/graphics/logo/logo_white.png" asp-append-version="true" alt="logo" />  

On the page I see only the html placeholter.

226038-image.png

The image path is fine I think.
How can I show a image from the project?

226023-image.png

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,390 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Zhi Lv - MSFT 32,011 Reputation points Microsoft Vendor
    2022-08-01T02:12:57.217+00:00

    Hi @Frank Mehlhop ,

     <img href="/graphics/logo/logo_white.png" asp-append-version="true" alt="logo" />    
    

    Please check your code, when specifies the path to the image, it should use the src attribute, instead of the href attribute.

    So try to change your code as below:

     <img src="/graphics/logo/logo_white.png" asp-append-version="true" alt="logo" />  
    

    Refer to the following screenshot:

    226470-image.png

    If still not working, try to clean and rebuild the project, and you can also use F12 developer tools to clear the cache.


    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,
    Dillion

    0 comments No comments