3
我必须在局部视图中显示PDF(作为BLOB存储在SQL Server表中)。我做相同的存储为table.The图像中的BLOB一个名为“.jpeg”的形象是越来越显示出来,但是,PDF isnt.I有下面的代码在我的控制器:在MVC中将PDF(作为BLOB存储)显示为图像
[Authorize]
public ActionResult Show3LeadImage(int id)
{
Byte[] imageData = null;
using (var scope = new PatientPersistenceScope())
{
searchRequest leadRequest = new searchRequest();
leadRequest.CaseNumber = id;
var mrx12LeadBitmap = _mrxSearchService.Get12Lead(leadRequest);
imageData = mrx12LeadBitmap.Data12Leads[0].mrx3Lead;
scope.Done();
}
return File(imageData,"image/png");//I have tried "FileContentResult,but it didnt work
}
中的代码局部视图(的.ascx)看起来是这样的:
<object data='<%= Url.Action("Show3LeadImage", "CareRecord", new { id = Model.CareRecord.CaseNumber}) %>' type="application/pdf" style="width: 721px; height: 800px;" ></object>
我没有访问到物理文件....的BLOB是我的所有。
甚至可以在部分视图中显示PDF作为图像吗?我遇到了很多文章,解释了如何使PDF在部分视图中可供下载。但我不希望我的文件可以下载。这个功能是可以实现的还是我想要做一些不可能的事情?
可以实现它轻松将您的PDF放在磁盘上,并保持其SQL路径。我想,这会降低SQL读取/写入时间。 –