繁体   English   中英

状态为200的“ responsetxt”中的http响应为空

[英]Empty http response in “responsetxt” with status 200

我的request.asp页中的以下代码:

<%
    url= "http://mydomainname.com/test.asp"
    dim http, pxml, http_response
    set http = createobject("MSXML2.ServerXMLHTTP")
    http.open "GET", url, 0
    http.setrequestheader "content-type", "text/xml; charset=utf-8"
    http.send ""
    response.write http.status
    response.write http.responseText
%>

这是test.asp页中的代码:

<%
    response.write "<response>test page<response>"
%>

在输出中, http.status为200,但是http.responseText为空,为什么?

我记得在microsoft.com上读过一些文章,如果返回的页面(在您的情况下为test.asp)没有正确的内容类型,则responseText和responseXML为空。 内容类型应为“ text / xml”或“ application / xml”。

您可以通过添加来查看发送了哪些标头

Response.Write Replace(http.getAllResponseHeaders(), Chr(13) & Chr(10), "<br />")

您的代码。

应该在test.asp中写的第一行是:

<?xml version="1.0" encoding="UTF-8" ?>

request.asp中的第一行应为:

<%response.ContentType="text/xml"%>

另外,请查看 request.asp的视图源 ,这样做可能会看到xml树

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM