ASP 中使用 HTTP 协议发送参数详解

2017 年 11 月 27 日4190

<%@LANGUAGE=“VBSCRIPT“CODEPAGE=“CP_ACP“%>
<html>
<head>
<metahttp-equiv=“Content-Type“content=“text/html;charset=Shift-JIS“>
<SCRIPTLANGUAGE=“JavaScript“>
<!--
functionSelText(){
varoRangeRef=document.body.createTextRange();
alert(oRangeRef.text);
}
//-->
</SCRIPT>
<%
functiongetHTTPPage(url)
dimHttp
setHttp=server.createobject(“MSXML2.XMLHTTP“)
'Http.open“GET“,url,false
Http.open“POST“,url,false
Http.send()
ifHttp.readystate<>4then
exitfunction
endif
'getHTTPPage=bytesToBSTR(Http.responseBody,“GB2312“)
getHTTPPage=bytesToBSTR(Http.responseBody,“Shift-JIS“)
sethttp=nothing
iferr.number<>0then
err.Clear
endif
endfunction

FunctionBytesToBstr(body,Cset)
dimobjstream
setobjstream=Server.CreateObject(“adodb.stream“)
objstream.Type=1
objstream.Mode=3
objstream.Open
objstream.Writebody
objstream.Position=0
objstream.Type=2
objstream.Charset=Cset
BytesToBstr=objstream.ReadText
objstream.Close
setobjstream=nothing

EndFunction
%>

<title></title>
</head>

<bodyonload=“SelText()“>
<%
DimUrl,Html
'Url=“http://localhost/CSharpWebAppTest/WebForm1.aspx?tmp=33333“
'Url=“http://localhost/CSharpWebAppTest/WebForm1.aspx“
Url=“http://www.whois.sc/221.216.169.120“
'Url=“http://localhost/akira/default.asp
Html=getHTTPPage(Url)
Response.writeHtml
%>
</body>
</html>

0 0