急求:asp中创建Microsoft.xmlhttp对象从服务器无法获取自己本地IIS运行出来的网页内容 的原因
asp中 创建Microsoft.xmlhttp或Msxml2.ServerXMLHTTP对象 服务器都无法获取自己本地IIS运行出来的网页内容
在有些Win2003上可以 有些Win2003上不可以,这一点说明源代码没有问题,环境都是Win2003SP2
是不是iis哪里的权限问题啊?
VBScript code
<%
Function getHTTPPage() 
  dim http 
  set http=Server.createobject("Msxml2.ServerXMLHTTP") 
  Http.open "GET","http://127.0.0.1/test.html",false
  Http.send() 
  if Http.readystate<>4 then
    exit function 
  end if 
  getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
  set http=nothing
  if err.number<>0 then Response.write(err.number) 
End function
Function BytesToBstr(body,Cset) 
  dim objstream
  set objstream = Server.CreateObject("adodb.stream")
  objstream.Type = 1
  objstream.Mode =3
  objstream.Open
  objstream.Write body
  objstream.Position = 0
  objstream.Type = 2
  objstream.Charset = Cset
  BytesToBstr = objstream.ReadText 
  objstream.Close
  set objstream = nothing
End Function
Response.write(getHTTPPage)
%>
------解决方案--------------------
'-----------------------本函数为远程获取内容的函数,URL即为网页地址,asp页面也行-----
Function GetBody(url)
Set Retrieval = CreateObject("Microsoft.XMLHTTP")  
With Retrieval  
.Open "Get", url, False, "", ""  
.Send  
GetBody = .ResponseBody
End With  
End Function
'--------------------------内码处理的函数,否则发送的邮件可能是乱码
Function BytesToBstr(strBody,CodeBase)  
       dim objStream  
       set objStream = Server.CreateObject("Adodb.Stream")  
       objStream.Type = 1  
       objStream.Mode =3  
       objStream.Open  
       objStream.Write strBody  
       objStream.Position = 0  
       objStream.Type = 2  
       objStream.Charset = CodeBase  
       BytesToBstr = objStream.ReadText 
       objStream.Close  
       set objStream = nothing  
End Function
response.write BytesToBstr(GetBody("http://127.0.0.1/test.html"),"gb2312")
这样试试呢