2012-09-22 69 views
2

我使用IIS在古典asp中发送pdf文档(由abcpdf 8生成)。iis7.5 Response.ContentType =“application/pdf”导致连接重置

什么都没有到达浏览器。

  • FF:连接已重置 - 加载页面时重置与服务器的连接。
  • IE:Internet Explorer无法显示网页 - Internet连接已丢失
  • Chrome:此网页不可用 - 错误101(net :: ERR_CONNECTION_RESET):连接已重置。

这是代码:

Set theDoc = CreateObject("ABCpdf8.Doc") 
theDoc.FontSize = 96 
thedoc.AddText "Hello World" 

theData = theDoc.GetData() 

Response.ContentType = "application/pdf" '<-- culprit? 
Response.AddHeader "content-length", UBound(theData) - LBound(theData) + 1 
Response.AddHeader "content-disposition", "inline; filename=MyPDF.PDF" 
Response.BinaryWrite theData   

如果我注释掉的ContentType行,浏览器加载的二进制数据,当然数据在浏览器中显示,并在此格式不可读。

回答

1

一位工作的同事解决了这个问题。

Response.BinaryWrite 
Response.flush '<-- this fixes it. 

如果有人知道为什么这个作品请添加评论。