无法使用经典的asp iis 7.5下载文件

时间:2012-09-18 06:50:29

标签: asp-classic connection download

我正在使用经典asp编码的客户端网站,其中iis 7.5和终端服务器上安装了windows server 2008 r2。我遇到的问题是当用户尝试下载jpg文件时。代码很好,并且在更改服务器之前工作正常,但现在当您单击下载链接时,您将获得以下页面之一:

The connection was reset                       ( Firefox)
Connection closed by remote server             (  Opera )
Internet Explorer cannot display the webpage   (   ie   )

只有在尝试从这些页面下载文件时才会发生这种情况,所有其他页面都按预期工作。我完全难以理解这个问题可能是什么,我已经花了好几个小时来浏览论坛和我能想到的任何事情。我猜这更像是一个后端配置问题,但我并不积极,也不知道需要改变什么才能让它再次运行。

2 个答案:

答案 0 :(得分:0)

可能存在任何问题。我建议运行Fiddler的副本以查看是否存在响应错误代码。

由于这是经典的asp,因此请检查代码中是否存在可能隐藏错误的内容。 这将是on error resume next。使用粗略的调试技术(如response.write "got here")或写入日志文件,通过代码查看停止的位置。

它可能根本不是IIS。我的猜测是文件许可问题。

要审核的其他链接:

How to guide for getting a classic asp application working under IIS 7.0

答案 1 :(得分:0)

此代码适用于iis 7.5 win2k8r2:


Sub s_getFile(sPath, sfilename, sBaseName)

Response.Buffer = False 
Server.ScriptTimeout = 30000 

Response.ContentType = "application/x-unknown" 

Response.AddHeader "Content-Disposition", "attachment; filename=" & sfilename 

Set adoStream = CreateObject("ADODB.Stream") 

adoStream.Open() 
adoStream.Type = 1 
adoStream.LoadFromFile(sPath & "\" & sBaseName) 

iSz = adoStream.Size 
可能需要

Response.AddHeader "Content-Length", iSz

chunk = 2048 
For i = 1 To iSz \ chunk 
    If Not Response.IsClientConnected Then Exit For 
    Response.BinaryWrite adoStream.Read(chunk) 
Next 

If iSz Mod chunk > 0 Then 
    If Response.IsClientConnected Then 
        Response.BinaryWrite adoStream.Read(iSz Mod chunk) 
    End If 
End If 

adoStream.Close 
Set adoStream = Nothing 

Response.End 
End Sub 
相关问题