网络.配置设置相当于htaccess Header set Content-disposition
web.config setting equivalent to htaccess Header set Content-disposition
为了下载pdf作为文件而不从服务器打开,我使用了一个很好的脚本download.js,它在Chrome中非常出色。但是正如作者在FF中警告的那样,它在一个单独的标签中打开下载的PDF -导致我的SPA导航问题。
他说在Apache这个代码在htaccess将修复它。我的应用程序在iis8上运行。我更喜欢在应用程序网络中处理它。如果可能的话配置。我可以把什么放进系统。webServer在我的Web。配置和/或管理在我的IIS共享主机提供商允许。(当然会在下面的代码中将pdf添加到FilesMatch中。)
//Easiest way to configure headers via Apache is to set Header set Content-Disposition "attachment" for files you want to be downloaded.
//So .htaccess can look like:
<FilesMatch "'.(zip|rar)$">
Header set Content-Disposition attachment
</FilesMatch>
多亏了在serverfault上发现的这一点(之前不知道这个站点),我能够将一个与上面问题中的htaccess语言等效的出站规则放在一起。(并在此过程中学到了一些奇妙的东西)我现在得到了我一直在寻找的Firefox下载行为,尽管我仍然需要找出处理未找到资源错误的最佳方法-欢迎提出建议。
<system.webServer>
<rewrite>
<outboundRules>
<rule name="Allow pdfs to be downloaded" preCondition="Only match pdfs">
<match serverVariable="RESPONSE_Content_Disposition" pattern="(.*)" negate="false" />
<action type="Rewrite" value="attachment" replace="true" />
<conditions>
<add input="{QUERY_STRING}" pattern="^download" />
</conditions>
</rule>
<preConditions>
<preCondition name="Only match pdfs">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^application/pdf" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
相关文章:
- Firebase迁移-简单的Firebase.set没有'不再工作了——旧的还是新的
- Ember Data DS.Model's set函数不起作用
- C#asp.net mvc Set CheckBoxFor已检查的具有Model Value的属性
- 为什么JavaScript可以'找不到给定的InnerHTML并返回Cannot set property
- CORS:否'访问控制允许来源'header-但是php设置头文件
- 无法在基于Cordova的应用程序中读取Set Cookie标头
- AngularJS Navigation (li ng-repeat, create header li), DOM
- 在不兼容的接收器上调用的方法Set.prototype.add未定义
- 为什么可以't我用Set对象调用Array.prototype.map
- Sequelize associations:set[Models]添加新模型,而不是关联现有模型
- 如何使用选项useCSS set true为bxSlider加载onSlideAfter()事件
- Node JS,传统的数据结构?(如Set等),任何类似Java.util的node
- Bootstrap-Datepicker not selecting date when using "set
- JQuery/Javascript来获取给定URL的Http Header详细信息
- Looking for function identical to lodash's [_.set]()
- Angular sqlLite set css url()无法设置相对路径
- Typerror:set 不是带有 angularjs 的函数
- 在使用 findAndModify 时$set运算符中将函数参数作为字段名称传递
- iframe - set Content Type header
- 网络.配置设置相当于htaccess Header set Content-disposition