请看下面的代码:
Controller :
public ActionResult GetPDF()
{
byte[] pdf = GetPdfFromDatabase();
return new FileContentResult(reportData, "application/pdf");
}
查看:
<iframe src="@Url.Action("GetPDF","Account")" width="600" height="500"></iframe>
Javascript 控制台:
Each time you load a page, show this warning !!!
最佳答案
iframe 请求 src 属性中提到的资源,内容类型为 text/html。所以这条消息只说“我请求了 html 但服务器以 pdf 响应”
关于asp.net-mvc - 资源解释为文档但使用 MIME 类型 application/pdf 传输,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39620917/