-2

Currently trying to build a company intranet, however the home page images I'm using aren't loading.

<div class="col-md-4">
    <img src="~/Views/Home/Icons/document.png" />
</div>

All images are in png format inside a folder next to the cshtml I'm trying to load them in.

1 Answer 1

1

Client image elements can not solve "~"

There are two ways to fix this:

  1. add runat="server" to your image elements
  2. use src='<%=ResolveClientUrl("~/image/a.jpg")%>'

UPDATES: sorry, I did not realize you are using MVC.

Then I think you should just move your images out of view folder. By default any resources under view folder are not accessible from client, that’s why you can not load your image

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

3 Comments

Thank you, this has solved the problem. I was getting a bit lost when the other answers to similar questions weren't fixing the issue.
there is no runat="server" in mvc.
@Fran check my updates. :) i did not notice he is using mvc at beginning

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.