0

I created an Images folder and placed a .gif image into the folder. I have a on my Index.cshtml page which should load the image. When I view the page in Chrome and look at the developers tools, I see in the console that the graphic image was not found. This is a picture of my application structure in Visual Studio 2019 as well as the code I have in the Index.cshtml page. I have tried referencing the image in the following ways:

<img src="~Images/loading.gif" />
<img src="/Images/loading.gif" />
<img src="~/Images/loading.gif" />
<img src="Images/loading.gif" />

Any idea why I would get a "Failed to load resource: the server responded with a status of 404 (Not Found) loading.gif error message?

Thank you.

enter image description here

2 Answers 2

3

I moved the Images folder under the wwwroot folder and I was able to access the image.

Sign up to request clarification or add additional context in comments.

Comments

0

Try right-click on the image in Visual Studio, go to properties, and update "Copy to Output Directory" to "Copy always" or "Copy if newer". This will ensure your image is copied to the output directory when you build the project.

4 Comments

Im on a Mac so there is no right click. I am able to Control-Click on the image file name and that gives me Quick Properties but the only option there is Copy to Output Directory. It is no checked.
I found the properties of the image file. I changed the setting to Copy always. I still have the same not found error
try updating path to src="../../Images/loading.gif"
I tried that as well. Still get the 404 error. The message comes back as GET localhost:5001/Images/loading.gif 404 (Not Found).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.