0
我正在使用MVC在視圖中顯示PDF內容,但它不能正確呈現。如何在MVC中顯示PDF流
控制器動作:
[HttpPost]
public ActionResult GetDocumentContent()
{
byte[] result;
result = System.IO.File.ReadAllBytes(@"C:\test.pdf");
Response.AppendHeader("Content-Disposition", new System.Net.Mime.ContentDisposition
{
FileName = "document.pdf",
Inline = true,
}.ToString());
return File(result, "application/pdf");
}
的Jquery:
var url = "/DocumentContent/GetDocumentContent";
var self = this;
$.post(url, null,function (data) {
debugger;
var obj = $('<object type="application/pdf" width="100%" height="100%" border="2"></object>');
obj.attr('data', data);
$('#divContainer').append(obj);
});
什麼是這個代碼錯誤了嗎?如何在View中顯示PDF流?
我需要使用POST方法,因爲我需要發送一些信息從客戶端到服務器(長度> url)。有什麼方法可以使用POST方法進行綁定? – user2015534
@ user2015534請參閱更新。 – Musa