.net mvc display image from file

controller:

public ActionResult Image(string id)
{
  var dir = Server.MapPath("/Images");
  var path = Path.Combine(dir, id + ".jpg");
  return base.File(path, "image/jpeg");
}

view:

<img src="@Url.Action("Image", new { id= Model.Guid })" alt="@Model.Name" width="300" >

关于“.net mvc display image from file”有一个评论

评论已关闭。