如何通过jQuery模式对话框返回PDF的MVC File ActionResult [英] How do I return MVC File ActionResult of PDF over jQuery modal dialog

查看:92
本文介绍了如何通过jQuery模式对话框返回PDF的MVC File ActionResult的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我不想以模态内联显示PDF.相反,我希望浏览器能够确认该文件并允许用户保存或打开它.

我在MVC 4中有一个jQueryUI模态对话框.该对话框是模态对话框.对话框的内容来自局部视图",可以很好地工作.对话框本身只有一个按钮,并且已经成功获取了所有JavaScript来处理客户端数据输入检查.

I have a jQueryUI modal dialog in MVC 4. The dialog IS modal. The content of the dialog is from a Partial Views which works fine. I have only one button on the dialog itself and have successfully gotten all the JavaScript to deal with client side data entry checking.

让我头疼的是,我在部分视图中嵌入了一个用于显示PDF文件的按钮.我可以成功调用一个JavaScript函数,该函数调用从另一台服务器获取文件的控制器.我什至可以将文件转换为字节数组,最后一行是 return File(contents, "application/pdf", "PropsedChanges.pdf");

What is giving me a headache is that I have one button embedded in the Partial View that is to display a PDF file. I can successfully call a JavaScript function that calls the controller that gets the file from another server. I can even get the file converted to a byte array and the last line is return File(contents, "application/pdf", "PropsedChanges.pdf");

但是它无法打开,因为我怀疑模式对话框阻止了它.

However it will not open as I suspect that the modal dialog is preventing it.

我在模型对话框之外做了类似的操作,它为我提供了IE屏幕底部的保存/打开选项,或在其他浏览器中的正确方式.

I have done something similar outside of the model dialog and it gives me the save/open option at the bottom of the screen for IE or in the correct manner in other browsers.

是否有一种方法可以在浏览器外部的客户端PC/设备上的注册的PDF查看器中显示PDF,而无需询问他们是否要保存或打开它?我怀疑由于模态对话框而没有发生.

Is there a way to display the PDF in a registered PDF viewer on the client's PC/Device outside of the browser needing to ask if they want to save or open it? Which, as I suspect, is not happening due to the modal dialog.

非常感谢您的帮助.

推荐答案

    public ActionResult GetPdf(Model modelo)
    {  
        return File(Pdf bytes[], "application/pdf");
    }

这篇关于如何通过jQuery模式对话框返回PDF的MVC File ActionResult的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆