ASP.NET MVC 4 Controllers @Html.ActionLink
本文关键字:@Html ActionLink Controllers NET MVC ASP | 更新日期: 2023-09-27 18:06:47
我试图从我的SQL数据库显示图像。在浏览器中,最终的显示应该如下所示:
1 |网络团队|我们是最好的部门!查看图片|编辑|删除
(注:"查看图片"、"编辑"、"删除"均为链接)
当用户点击"查看图像"链接时,我希望数据库中存储的图像URL显示实际图像。
下面是我的View的代码:
@Html.ActionLink("View Image", "viewImage", new { id = Department.Picture })
这里是我的控制器的代码:
public class ViewImageController : Controller
{
public ActionResult viewImage(int Id)
{
return View();
}
}
你知道我做错了什么吗?
试试这个:
public ActionResult viewImage(int Id)
{
Byte[] byteArray = MODEL.TABLE_NAME.Where(i =>colum_name == id).Select(i => i.FILE_DATA).Single();
return File(byteArray, "image/png");
}