值得关注的invoke Method
Sys.Net.WebRequest invoke Method
执行Web请求
Sys.Net.WebRequestManager.invoke(WebRequest);
异常:
Sys.InvalidOperationException 最多只能调用一次
如果你已经注册completed request event handler为你的Sys.Net.WebRequest 实例,按照网络堆异步调用handler的请求过程.一个WebRequest实例中只能调用一个invoke.如果网络请求已经发出就会抛出一个异常.
怎样使用:
执行Web请求
Sys.Net.WebRequestManager.invoke(WebRequest);
异常:
Sys.InvalidOperationException 最多只能调用一次
如果你已经注册completed request event handler为你的Sys.Net.WebRequest 实例,按照网络堆异步调用handler的请求过程.一个WebRequest实例中只能调用一个invoke.如果网络请求已经发出就会抛出一个异常.
怎样使用:
// This function sets an HTTP header for
// the Web request.
function WebRequestHeader()
{
// Instantiate the WebRequest object.
var wRequest = new Sys.Net.WebRequest();
// Set the request Url.
wRequest.set_url(postPage);
// Set the request verb.
wRequest.set_httpVerb("POST");
var body = "Message=Hello! Do you hear me?"
wRequest.set_body(body);
// Set the value of the HTTP header's "Content-Length".
wRequest.get_headers()["Content-Length"] = body.length;
// Set the web request completed event handler,
// for processing return data.
wRequest.add_completed(OnWebRequestCompletedHeader);
// Clear the results page element.
GetElementById("ResultsId").innerHTML = "";
// Execute the request.
wRequest.invoke();
}
// the Web request.
function WebRequestHeader()
{
// Instantiate the WebRequest object.
var wRequest = new Sys.Net.WebRequest();
// Set the request Url.
wRequest.set_url(postPage);
// Set the request verb.
wRequest.set_httpVerb("POST");
var body = "Message=Hello! Do you hear me?"
wRequest.set_body(body);
// Set the value of the HTTP header's "Content-Length".
wRequest.get_headers()["Content-Length"] = body.length;
// Set the web request completed event handler,
// for processing return data.
wRequest.add_completed(OnWebRequestCompletedHeader);
// Clear the results page element.
GetElementById("ResultsId").innerHTML = "";
// Execute the request.
wRequest.invoke();
}