.NET 7 API project can't find images

44 Views Asked by At

I began with a standard .NET 7 Web API project that runs fine. I ran into a situation where I need to return a one-off view and I didn't want to create another project to serve views so I added a normal controller to the project with a method to return said view. The view gets returned as expected but none of the resource links work, including images.

So this html:

<a href="index.html" class="logo">
    <img src="images/popupshop.svg" alt="">
</a>

returns this view:

boken image link

This is how I have added the image to the product:

visual studio project

Not sure what else I'm missing?

1

There are 1 best solutions below

0
Cef On BEST ANSWER

Adding:

app.UseStaticFiles();

to the Program.cs allowed the paths to work