asp.net-mvc - 资源解释为文档但使用 MIME 类型 application/pdf 传输

标签 asp.net-mvc html pdf

请看下面的代码:

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 控制台:

enter image description here

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/

相关文章:

javascript - .click 在 Javascript 中没有任何效果 - 应该更新基于数组的两个元素

c# - 使用 DisplayFormat 时未在 View 中设置日期格式

jquery - IE11和IE10中的模糊事件功能

c# - MVC 中的 web api 不再工作

php - 如何使用最后一页上设置的变量动态填充新页面?

iphone - 从 PDF 文件中搜索字符串/文本并在 iPhone/iPad 应用程序中列出所有匹配的字符串

asp.net - 如何处理表单提交 ASP.NET MVC 返回按钮?

html - 通过识别超链接导出R中的html表

pdf - 下载文件名是如何选择的?有没有办法更改它?

PHP 发送到 Outlook PDF 文件