.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》有1个想法

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注