Hi guys,
I have noticed the following code in the abort function of the Sys.Net.XMLHttpExecutor class:
var a=this._webRequest._get_eventHandlerList().getHandler("completed");
if(a)
a(this,Sys.EventArgs.Empty)
The documentation states that the completed event of the WebRequestManager is raised when the request is completed, timed out or aborted.
Maybe the code should be:
a._webRequest.completed(Sys.EventArgs.Empty);
like in the case when the request is completed or timed out.
Is thig a bug or a feature?
Bogdan
The executor sets the Web request state to aborted. This means that the XMLHttpExecutor Class instance's started Property and aborted Property methods both return true.Next the WebRequestManager Class instance calls the completed event handler on the associated request object.
After the abort method is called, the state of the response returned by the executor's methods is undefined.
You can call the abort method multiple times. However, the second and subsequent calls are not processed. The completed event handler is raised only once.
You get an exception if you call the abort method before you call the executeRequest Method method.
The unique document?about?Sys.Net.XMLHttpExecutor we can use is from?here?-?http://ajax.asp.net/docs/ClientReference/Sys.Net/XmlHttpExecutorClass/default.aspx
Try to take a look at it and get some ideas from it.
Thank you for your response! Perhaps I didn't make it clear enough .. I agree on what you said about the abort method and what happens if it is called multiple times but my concerns are related to the completedRequest event of the WebRequestManager that is no longer raised in this case.
When a request is timed out the _onTimeout event handler is called and thus the WebRequest's completed event is called:
this._onTimeout=function(){
if(!a._responseAvailable){
a._clearTimer();
a._timedOut=true;
a._xmlHttpRequest.onreadystatechange=Function.emptyMethod;
a._xmlHttpRequest.abort();
a._webRequest.completed(Sys.EventArgs.Empty);
a._xmlHttpRequest=null
}
}
By Calling the completed method of the underlying WebRequest the completedRequest event of the WebRequestManager and also the completed event of the WebRequest are raised and all the registered event handlers notified.
Likewise in the XMLHttpExecutor class when the request completes the same completed method of the WebRequest is invoked:
this._onReadyStateChange=function(){
if(a._xmlHttpRequest.readyState===4){
a._clearTimer();
a._responseAvailable=true;
a._webRequest.completed(Sys.EventArgs.Empty);
if(a._xmlHttpRequest!=null){
a._xmlHttpRequest.onreadystatechange=Function.emptyMethod;
a._xmlHttpRequest=null
}
}
};
Like in the first case the completedRequest event is also raised.
When the request is aborted the completedRequest is not raised any more :
abort:function(){
if(this._aborted||this._responseAvailable||this._timedOut)
return;
this._aborted=true;
this._clearTimer();
if(this._xmlHttpRequest&&!this._responseAvailable){
this._xmlHttpRequest.onreadystatechange=Function.emptyMethod;
this._xmlHttpRequest.abort();
this._xmlHttpRequest=null;
var a=this._webRequest._get_eventHandlerList().getHandler("completed");
if(a)
a(this,Sys.EventArgs.Empty)
}
}
};
What do you think about the above mentioned? Do they represent the correct behavior?
Thanks in advance,
Bogdan
Phew !!
Check out this post:
http://forums.asp.net/thread/1537056.aspx
They have finally realized the bug.. Probably it'll be fixed in the RTM release..
Bogdan
No comments:
Post a Comment