大家好我绑定了img
标签,如下所示
<img alt="" src='@Url.Action("UserImage", "Home")' class="avatar img-circle img-thumbnail" />
这是我从数据库中获取图像的代码
[HttpGet]
public ActionResult UserImage()
{
string user = Session["UserName"] as string;
byte[] photo = null;
var v = db.table.Where(p => p.USER_NAME == user).Select(img => img.PHOTO).FirstOrDefault();
if (v != null)
{
photo = v;
return File(photo, "image/jpeg");
}
else
return null;
}
当我在数据库中时显示图像但是当它为null时它显示如下,而不是我需要将src标记绑定为空