加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 资源解释为Document但使用MIME类型application/p

发布时间:2020-12-16 04:01:40 所属栏目:asp.Net 来源:网络整理
导读:请参阅以下代码: 控制器: public ActionResult GetPDF(){ byte[] pdf = GetPdfFromDatabase(); return new FileContentResult(reportData,"application/pdf");} 视图: iframe src="@Url.Action("GetPDF","Account")" width="600" height="500"/iframe Jav
请参阅以下代码:

控制器:

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 !!!

解决方法

谁遇到这个话题. (我也是.)为了获得最佳解决方案,您需要创建HTML页面以充当iframe登录页面以显示PDF内容.

这是示例html.我只是从铬中提取.

<html><body style="background-color: rgb(38,38,38); height: 100%; width: 100%; overflow: hidden; margin: 0px;"><embed width="100%" height="100%" name="plugin" id="plugin" src="your_pdf_url" type="application/pdf"></body></html>

只需将your_pdf_url替换为您的真实网址即可.我只是在Laravel中将此html添加为中间件并显示此HTML,以便Chrome不再发出警告.您可以使用此html作为基础,并创建更好的pdf登录页面,如自定义加载.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读