I have the following code in my view:
<div class="container">
<div class="row">
@foreach (var item in Model)
{
<div class="col-lg-3 col-md-4 col-xs-6 thumb">
<a class="thumbnail" href="#">
<div class="caption">
<h4>Thumbnail Headline</h4>
<p>@Html.DisplayFor(modelItem => item.ImageCaption)</p>
</div>
<img class="img-responsive" src="@Html.DisplayFor(modelItem => item.ImageFilePath)" alt="">
</a>
</div>
}
</div>
</div>
@Html.DisplayFor(modelItem => item.ImageFilePath)
returns a relative image path that is stored in a database in the following format: "~/Content/userProfiles/profile01/image.JPG".
When my view is rendered, my image appears to have a broken link (it is not displayed). However, when I hard-code the path in the image source it displays as required. Stated differently, <img class="img-responsive" src="@Html.DisplayFor(modelItem => item.ImageFilePath)" alt="">
returns a broken link where <img class="img-responsive" src="~/Content/userProfiles/profile01/image.JPG" alt="">
displays the image.
Why isn't my image displayed using the html helper even though it returns a path that works when hard-coded into the view? .