Asp classic 服务器XMLHttp导致IE 8中的页面永远执行?

Asp classic 服务器XMLHttp导致IE 8中的页面永远执行?,asp-classic,Asp Classic,我有一个名为Error1.asp的页面中的以下代码。但无论何时运行,发布数据的页面都不会显示。需要显示的是“default1.aspx”,但它从未在IE8中呈现。在Firefox和Chrome中,它使用与下面相同的代码进行渲染,没有任何问题。 如何使这个ServerXMLHttp在IE8中工作?我在我的电脑上赢了7个64位 Set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP") xmlhttp.Open "POST","http://

我有一个名为Error1.asp的页面中的以下代码。但无论何时运行,发布数据的页面都不会显示。需要显示的是“default1.aspx”,但它从未在IE8中呈现。在Firefox和Chrome中,它使用与下面相同的代码进行渲染,没有任何问题。 如何使这个ServerXMLHttp在IE8中工作?我在我的电脑上赢了7个64位

Set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open  "POST","http://localhost/ClassicASPErrorHandling/default1.aspx",false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

xmlhttp.send   "errorDesc=" & Server.HTMLEncode(Server.GetLastError().Description() )& "&errorDetailedDesc=" & Server.HTMLEncode(Server.GetLastError().ASPDescription()) & "&errorURL=" & strURL & "&errorLineNumber=" & Server.HTMLEncode(ASPErr.Line()) & "&errorFile=" & Server.HTMLEncode( ASPErr.File()) & "&errorSource=" & Server.HTMLEncode(ASPErr.Source()) & "&logonUser="  & strLogonUser & "&errorCode=" & Server.HTMLEncode(Server.GetLastError().ASPCode() )
Response.Write xmlhttp.responseText
Response.ContentType = "text/xml"
Response.Write xmlhttp.responsexml.xml
Set xmlhttp = nothing

我怀疑这是一个浏览器问题,我认为发生的情况是您在页面上显示内容,然后更改内容类型,即可能无法理解这一点,因此,请尝试在代码中进行此更改,看看是否可行:

 Set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP")
 xmlhttp.Open  "POST","http://localhost/ClassicASPErrorHandling/default1.aspx",false
 xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

 xmlhttp.send   "errorDesc=" & Server.HTMLEncode(Server.GetLastError().Description() )& "&errorDetailedDesc=" & Server.HTMLEncode(Server.GetLastError().ASPDescription()) & "&errorURL=" & strURL & "&errorLineNumber=" & Server.HTMLEncode(ASPErr.Line()) & "&errorFile=" & Server.HTMLEncode( ASPErr.File()) & "&errorSource=" &      Server.HTMLEncode(ASPErr.Source()) & "&logonUser="  & strLogonUser & "&errorCode=" & Server.HTMLEncode(Server.GetLastError().ASPCode() )

 Response.ContentType = "text/xml" //THIS SHOULD HAPPEN BEFORE USING RESPONSE.WRITE

 Response.Write xmlhttp.responseText //DO NOT DO THIS UNLESS DATA IS XML BECAUSE OF CONTENTTYPE
 Response.Write xmlhttp.responsexml.xml
 Set xmlhttp = nothing

如果您试图在
ContentType=“text/XML”
页面上显示非XML数据,我可以向您保证IE可能是第一个出现问题的浏览器。确保写入页面的唯一内容是XML或更改您的
ContentType=“text/html”

答案已经被接受,但是为了其他读者的利益,代码应该是这样的:-

 Dim xmlhttp: Set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP") 
 xmlhttp.Open "POST", "http://localhost/ClassicASPErrorHandling/default1.aspx", false 
 xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" 

 Dim lastErr: lastErr = Server.GetLastError()
 Dim entityBody: entityBody = "errorDesc=" & Server.URLEncode(lastErr.Description) _
      & "&errorDetailedDesc=" & Server.URLEncode(lastErr.ASPDescription) _
      & "&errorURL=" & Server.URLEncode(strURL) _
      & "&errorLineNumber=" & lastErr.Line _
      & "&errorFile=" & Server.URLEncode(lastErr.File) _
      & "&errorSource=" & Server.URLEncode(lastErr.Source) _
      & "&logonUser="  & strLogonUser _
      & "&errorCode=" & lastErr.ASPCode 

 xmlhttp.send Replace(entityBody, "+", "%20")

 Response.ContentType = "text/html"  

 Response.Write xmlhttp.responseText 

我真的很感激你的回答。它解决了我的问题。我不得不改为:Response.ContentType=“text/html”,并将内容类型行放在所有写入之前。您能否澄清我是否需要删除您注释“//除非数据是XML,否则不要这样做…”的行?我现在使用的是“text/html”。再次感谢。