What is the correct way to reference an image in an asp.net mvc 4 project?

Try src="@Url.Content("~/Images/backup5.jpg")".


For the benefit of those who are not working on an MVC project, they can use:

<img src="../Images/yourImage.png" height="yourHeight" width="yourWidth"/>

where Images is a new folder added to the existing project and yourImage.png can be added to that folder by doing right-hand click on the Images folder, selecting Add and then Existing item, and navigating to where the file is stored.


@Url.Content("~/Images/backup5.jpg") Seems like a decent way to do it.


You should be using the Url.Content helper with the tilda ~ marker (which resolves to the root of the application):

src="@Url.Content("~/Images/backup5.jpg")"