Asp.net mvc retriev images from db and display on Page
- by Trey Carroll
//Inherits="System.Web.Mvc.ViewPage<FilmFestWeb.Models.ListVideosViewModel>"
<h2>ListVideos</h2>
<% foreach(BusinessObjects.Video vid in Model.VideoList){%>
<div class="videoBox">
<%= Html.Encode(vid.Name) %>
<img src="<% vid.ThumbnailImage; %>" />
</div>
<%} %>
//ListVideosViewModel
public class ListVideosViewModel
{
public IList<Video> VideoList { get; set; }
}
//Video
public class Video
{
public long VideoId { get; set; }
public long TeamId { get; set; }
public string Name { get; set; }
public string Tags { get; set; }
public string TeamMembers { get; set; }
public string TranscriptFileName { get; set; }
public string VideoFileName { get; set; }
public int TotalNumRatings { get; set; }
public int CumulativeTotalScore { get; set; }
public string VideoUri { get; set; }
public Image ThumbnailImage { get; set; }
}
I am getting the "red x" that I usually associate with image file not found. I have verified that my database table shows <binary data> after the stored proc that uploads the image executes. Any insight or advice would be greatly appreciated.