【发布时间】:2009-02-01 12:46:52
【问题描述】:
K...我在做一些明显错误的事情。我有一个简单的页面,上面有一个文件输入控件和一个提交按钮。我正在尝试使用 Mvc RC 发布的新“文件”ActionResult...
所有,我想要发生的是当单击提交按钮时,选定的文件被上传到数据库。这一切都很好......
然后,在页面刷新后,我想要一张图片来显示上传的结果图片。问题是图像未呈现...我得到损坏的图像...
这是获取文件并将其发送回视图的部分...
var a = Helper.Service.GetAttachmentById(id, MembershipProvider.SecurityTicket);
if (a == null)
{
return View(new ImagePlaceHolderViewData(new { Id = id }));
}
return View(new ImagePlaceHolderViewData(new { Id = a.Id, Image = a, FileContent = File(a.Data, a.ContentType) }));
然后在视图中我有一个像这样的图像标签......
<img src="<%=Model.FileContent.FileContents %>" />
我也试过了……
<img src="<%=Model.FileContent%>" />
想法..??
【问题讨论】:
标签: c# asp.net-mvc