Provide the PhotoPath as a property on your viewmodel:
public class UserViewModel
{
//...
public string PhotoPath { get; set; }
}
Controller:
public ActionResult Show(int id)
{
// load User entity from repository
var viewModel = new UserViewModel();
// populate viewModel from User entity
return View(viewModel);
}
View:
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<UserViewModel>" %>
...
<img src="<%= Model.PhotoPath %>" alt="User Photo" />
...
You could also pass the User
entity directly to the view, but it's not recommended to do that. But if you want to do it this way, then you have to change the view's page directive accordingly:
<%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<User>" %>