从Win2003迁移到Win2008 IIS7时,经典ASP方法不起作用?

时间:2010-11-29 15:39:09

标签: iis-7 vbscript asp-classic windows-server-2008

我刚刚将一个旧的经典ASP网站从win2003 IIS6盒子移到Win2008R2 IIS7盒子上,除了一件事之外,它们都运行良好。

我有一个让用户下载CSV订单的方法,方法如下:

sub DownloadOrders()
Response.clear
'Send headers for file name and content type changes
Response.AddHeader "Content-Disposition", "attachment; filename=orders.csv"
Response.ContentType = "application/text"

for I = 0 to ubound(theorderslist,2)
if I = 0 then
Response.Write("Order No,Date,Name,Address,Town/City,Country,Sub Total,Tax,Shipping,Total,Status" & vbCrLf)
end if
    Response.Write("" & pOrderPrefix & "-" & theorderslist(0,I) & "," & theorderslist(3,I) & "," & theorderslist(5,I) & " " & theorderslist(7,I) & "," & Replace(theorderslist(8,I),","," ") & "," & Replace(theorderslist(12,I),","," ") & "," & theorderslist(13,I) & "," & theorderslist(14,I) & "," & theorderslist(15,I) & "," & theorderslist(16,I) & "," & theorderslist(4,I) & "," & orderStatusDesc(theorderslist(10,I)) & vbCrLf)
next
Response.End
end sub

现在,如果我点击链接,我得到的是404错误?我甚至给了目录完全修改权限但仍然没有运气?任何想法我还能尝试什么?

如上所述,这在Win2003盒子上已经完美运行了多年:(

4 个答案:

答案 0 :(得分:1)

我正要问一个类似的问题,但@stealthyninja用他精简的测试代码让我走上正轨。

就我而言,我文件中的罪魁祸首是:

Response.AddHeader "Content-Length", objFile.Size

有一次我评论说排除了一切正常,这导致我this SO question about content-length帮助追踪我的真实问题。

答案 1 :(得分:0)

答案 2 :(得分:0)

@ leen3o:听起来好像在IIS中没有定义application/text MIME类型。本指南中包含了如何手动添加它:http://www.iis.net/ConfigReference/system.webServer/staticContent/mimeMap

<强>更新

将以下精简版Sub保存到行为不当的服务器上的testcsv.asp并直接访问它。如果生成的CSV文件没有错误,那么IIS7不喜欢的东西必须放在代码的其他地方,你需要再粘贴一点,这样我们就可以帮你调试了。

Response.AddHeader "Content-Disposition", "attachment; filename=orders.csv"
Response.ContentType = "application/text"
Response.Write("Order No,Date,Name,Address,Town/City,Country,Sub Total,Tax,Shipping,Total,Status" & vbCrLf)
Response.End

答案 3 :(得分:0)

生成CSV文件的脚本上的文件类型扩展名是什么?

IIS不会提供未注册MIME类型的文件类型,而是返回404

此外,如果未映射application/text MIME类型,则stealthyninja会说明IIS也不会提供文件

刚刚在我的Windows Server 2008开发计算机上检查了我的IIS7实例,并且默认情况下我没有注册应用程序/文本。

相关问题