如何在路径存储在数据库中的图像控件中显示图像。 请提供示例代码我已经从数据库获取路径,但我如何在图像控制中显示。 这是我的代码
[HttpPost]
public ActionResult DisplayPic()
{
string UserName=User.Identity.Name;
var getPath = from p in Session.Query<Registration>()
where p.Email == UserName
select p.Path;
if (getPath.Count() > 0)
{
//display pic???
}
return View();
}
查看:
@{
ViewBag.Title = "DisplayPic";
}
<h2>DisplayPic</h2>
@using (Html.BeginForm())
{
<img alt="" src="" width="200" height="200" />
}
答案 0 :(得分:2)
将图像路径存储在模型属性中并使用
<img src="@Url.Content(Model.ImagePath)" alt = "Image" />