我是我的 asp.net mvc 应用程序,我有一个
<li class="thumpimage">
<%=Html.Hidden("attachmtId", item.ILDAttachmentId) %>
<img src="<%=imgurl %>" alt="test" height="81" width="76" />
<span class="thumb_descrp">
<%=item.ILDAttachmentName %></span></li>
jquery部分如下
$(document).ready(function() {
$(".thumpimage").click(function() {
var attchmtId = $("#attachmtId").val();
alert(attchmtId);
$.post('/Instruction/OpenInstnDoc', { attchId: attchmtId });
});
});
控制器中的功能是
public ActionResult OpenInstnDoc(int attchId)
{
Attachment objAttach = new Attachment();
objAttach = objAttach.GetAttachmentById(attchId);
byte[] theData = objAttach.BinaryFile;
Response.AddHeader("content-length", theData.Length.ToString());
Response.AddHeader("content-disposition", "inline; filename=" + objAttach.AttachmentName + "");
return File(theData, objAttach.MineType);
}
我无法打开文件。谁可以帮我这个事?