skip to Main Content

In my project I have an image folder inside of the wwwroot folder of my .net razor pages project.
this image folder is set up like this:
image/
nfl/
logos/
.
.
.
nfl.png

In my index.chtml I know I could just do to get the nfl.png logo to render. however, when I try to do something like where LeagueID = "nfl" the picture never loads. does anyone know why?

I have tried to word how the url in the src of the img tag is worded but I just cant get the img to load.

2

Answers


  1. Can you provide the more detail about the code, like which code you are using in your CS and HTML file?

    Login or Signup to reply.
  2. Try using Url.Content method that will give you path to the static asset:

    Url.Content(@"image/nfl/logos/...nfl.png");
    

    Example

    Having such setup

    setup

    below works like a charm:

    <img src="@Url.Content(@"images/piesio_v2.png")" />
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search