I've got a list of data that I need to display. Each item has an image field that is pulled from the database.
If the image is null it needs to display a random stock image from the server.
I wanted to do something like:
<img src='@Url.Action("GetImage", "MeetTheTeam", new { id = TeamMate.Id })' />
and then in the controller:
public ActionResult GetImage(int id)
{
var item = team.Where(teammate => teammate.Id == id).SingleOrDefault();
if (item.Image != null)
{
return File(item.Image, "image/jpg");
}
else
{
return Content(AppSettings.AppRoot + "content/images/MeetTheTeam/v2/gray-block" + random.Next(1, 14) + ".jpg");
}
}
But this is not working, and I can't debug into the controller...
Is this even possible?