ASP.NET Response.BinaryWrite文件下载是使用SSL阻止的

Gai*_*din 5 asp.net

我有一个生成动态文件供下载的页面,并使用Response.BinaryWrite将其发送到客户端.

一切似乎工作正常,除非我们将其移动到使用SSL的测试服务器.下载发生在一个新窗口中,我所看到的(在IE7/8但不是chrome或FF)是选项卡打开并关闭,但没有显示文件对话.

这是完整的标题写:

Response.Clear()
        Response.Buffer = True
        Response.ContentType = "application/octet-stream"
        Response.AddHeader("Content-Length", abytFileData.Length.ToString)
        Response.AddHeader("cache-control", "private")
        Response.AddHeader("Expires", "0")
        Response.AddHeader("Pragma", "cache")
        Response.AddHeader("content-disposition", "attachment; filename=""" & pMsg!pstrFileName & """")
        Response.AddHeader("Accept-Ranges", "none")
        Response.BinaryWrite(abytFileData)
        Response.Flush()
        Response.End()
Run Code Online (Sandbox Code Playgroud)

我确信我的问题是这里提到的,

但我的缓存控制标准是正确的.有任何想法吗?

小智 2

我遇到了同样的问题,经过一定程度的调查后,我发现 codeproject 上的一篇文章表明 IE 安全设​​置阻止了下载。如果您转到“工具”->“Internet 选项”->“安全”选项卡并查看您正在访问的区域的“下载”选项,则需要将“文件下载自动提示”更改为“启用”。“Internet”区域默认设置为禁用。这是我提到的文章的链接: http: //www.codeproject.com/KB/aspnet/SecureFileDownload.aspx