I have a mvc 4 project where I am using image references that look like this:
<img alt="Progress Update" class="projectListNotificationIcon" src="@Url.Content("~/Images/progressUpdateIcon.png")"/>
The @Url.Content is necessary for it to work on both the local copy of this project, as well as the live server copy. This works great, however I have another place where I am choosing between 2 different images and tha code looks like this:
var imagePath = (item.IsOverdue) ? "../../Images/lateIcon.png" : "../../Images/onTimeIcon.png";
How can I use some permutation of the @Url.Content in my if statement above? The current way that I am doing it works in the local project, but not on the server.
Try:
Use of the tilde (~) sign is probably the key, as that resolves the url relative to the root of the site.