IE8将无法下载文件具有自定义MIME /类型与启用UAC [英] IE8 won't download a file with a custom mime/type with UAC enabled

查看:1204
本文介绍了IE8将无法下载文件具有自定义MIME /类型与启用UAC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地计算机上运行的.NET服务(Windows 7 64位系统,IE8,.NET 3.5,C#)返回一个文件到浏览器响应用户操作。使用Firefox或Chrome,该文件被正确下载,我们的应用程序是通过自定义MIME类型推出,一切都很好。

I have a .net service running on the local machine (Windows 7 x64, IE8, .net 3.5, C#) that returns a file to the browser in response to a user action. Using firefox or chrome, the file is downloaded properly and our application is launched via a custom mime type and all is well.

不过,随着IE8,我收到一个对话框无法从下载文件。无法打开此Internet站点。请求的站点不可用或无法找到。请稍后再试。

However, with IE8, I receive a dialog "unable to download file from . Unable to open this internet site. The requested site is either unavailable or cannot be found. Try again later".

使用招,我核实, IE浏览器从服务接收的有效载荷。

Using fiddler, I verified that IE does receive the payload from the service.

如果我关闭UAC,IE浏览器下载文件并启动相关的应用程序。

If I turn off UAC, IE does download the file and launch the associated application.

关闭UAC是不是一个可行的解决方案,我们的客户将有它启用。

Turning off UAC is not a viable solution, as our customers will have it enabled.

我怎样才能得到IE8启动相关的应用程序启用UAC

How can I get IE8 to launch the associated application with UAC enabled?

编辑:

描述了编程ID重新注册MIME类型后的这里,我可以让IE打开显示打开或保存对话框中的链接从地址栏要求的第二次。为什么它不工作的第一次?

After reregistering the mime type with a programmatic id as described here, I can get IE to open show the "Open or Save" dialog for the SECOND time the link is requested from the address bar. Why doesn't it work the first time?

推荐答案

我今天能解决这个问题。原来,代码隐藏在响应的 CacheControl 属性设置为 HttpCacheability.NoCache 。删除该行代码解决了这个问题。此修复程序的另一半正确使用注册一个ProgID的MIME类型和文件扩展名。

I was able to solve this issue today. It turns out that the codebehind was setting the CacheControl property of the response to HttpCacheability.NoCache. Removing that line of code solved the issue. The other half of the fix was correctly registering the mime type and file extension with a ProgId.

我剥离下来的反应,只是内容处置:附件;文件名= XXX 和字符串数据的二进制写。 IE正确显示打开或保存对话框,即使MIME探查报告的文件为text / html(这确实应该是text / plain的)。

I stripped down the response to just content-disposition: attachment; filename=xxx and a binary write of the string data. IE correctly displayed the Open or Save dialog box, even though the mime sniff reported the file as text/html (which really should have been text/plain).

我重新添加内容类型头并重新测试,那么nosniff选项并重新测试,最后是高速缓存控制。在每次测试之间,我重新启动虚拟机,以确保它是一个原始的测试环境(即没有缓存或预装)。只有高速缓存控制线影响以负面方式的行为。

I added back the content type header and retested, then the nosniff option and retested and finally the cache control. In between each test, I rebooted the VM to ensure it was a pristine testing environment (ie, nothing cached or preloaded). Only the cache control line affected the behavior in a negative fashion.

这篇关于IE8将无法下载文件具有自定义MIME /类型与启用UAC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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