87,996
社区成员




/// <summary>
/// 处理web请求
/// </summary>
/// <param name="context"></param>
public void ProcessRequst(HttpListenerContext context)
{
//得到请求
if (context.Response != null)
{
//得到html
string strHtml = ControlManager(context);
//返回客户端的html
if (!string.IsNullOrEmpty(strHtml))
{
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strHtml);
context.Response.ContentLength64 = buffer.Length;
context.Response.KeepAlive = false;
context.Response.OutputStream.Write(buffer, 0, buffer.Length);
context.Response.OutputStream.Flush();
context.Response.OutputStream.Close();
}
}
}
function RequestTest() {
var xmlHttp;
var url = "";
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
xmlHttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
alert(xmlHttp.responseText);
document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
}
}
}
xmlHttp.open("GET", url, true);
xmlHttp.send();
}
function RequestTest() {
var xmlHttp;
var url = "http://xxx.xxx.xxx.xxx:80/time=0";
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
document.getElementById("content").innerHTML = xmlHttp.responseText;
setTimeout("RequestTest() ", 2000);
}
}
}
xmlHttp.open("GET", url, true);
xmlHttp.send();
}