English 中文(简体)
Asp.net MVC 档案中心——防止浏览器开张
原标题:Asp.net MVC FileContentResult - prevent opening in browser

我的一个控制者行动将档案归还用户。 我想向用户提供下载(公开/假)方言,而不论档案类型如何。 如果档案类型为:doc、docx、xlsx等,但当档案为txt、xps、pdf(有时是)或.html时,该档案在浏览器上打开。

Is there a way I can prevent the file from opening in the browser, and only allow the user to open it in a separate window without navigating away from the current page?

申请使用jQuery s$.ajax({})

与此相关:browser处理申请,并给予与AJAX电话相比的登峰,作为复方,可在上解释,但这一问题涉及强迫浏览器在收到档案后以某种方式处理。

最佳回答

我不认为你可以在客户的指挥或环境下这样做。 您需要在服务器上做一些事情,以便每个档案中填写一个内容类型的>/application/octet-stream。 否则,浏览器将依据自己的规则和能力,检查即将到来的档案,并决定与它做些什么。

如果您能在服务器上这样做,则尝试制定<条码>“Content-Disposition”Hetor to attachment;文档名称=whatever.xyz”

问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签