jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了流式传输一个byte []以在jquery模式中加载为PDF(MVC3)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
当使用MVC3单击某个链接时,我正在尝试流式传输一个byte []以加载到jquery模式中.
在我的控制器中我有
public ActionResult GetTermsAndCondtion()
        {
            byte[] termsPdf = GetTermsAndConditions(datetiR_727_11845@e.Now);              
            return new FileContentResult(termsPdf,"application/pdf");
        }

我有一个观点

@Html.ActionLink("Terms and Conditon","GetTermsAndCondtion","Customer",new{id="terms"})

这将在选项卡中打开pdf文件.但我想在一个模态中打开byte []作为pdf文件.

任何帮助?

解决方法

iframe可能是你的答案.

问题是ajax无法在浏览器中加载pdf,显示pdf你必须指定内容配置并且浏览器在他里面显示pdf

指定内容处置添加标题

httpContext.response.addheader("content-disposition","inline; filename=MyFile.pdf")
Return File(fileStream,"application/pdf")

调节器

public ActionResult GetTermsAndCondtion()
        {
            byte[] termsPdf = GetTermsAndConditions(datetiR_727_11845@e.Now);
            httpContext.response.addheader("content-disposition","inline; filename=MyFile.pdf");

            return File(termsPdf,"application/pdf");
        }

最后在你的模态中添加这个iframe

<iframe src="@url("GetTermsAndCondtion","NameOfYourController")" width="400" height="500" scrolling="auto" frameborder="1">
</iframe>

大佬总结

以上是大佬教程为你收集整理的流式传输一个byte []以在jquery模式中加载为PDF(MVC3)全部内容,希望文章能够帮你解决流式传输一个byte []以在jquery模式中加载为PDF(MVC3)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。