I’m having a problem described and solved at the following link
… However I cannot use the recommended solution (Use Client HTTP stack) since I’m using JavaScript and not Silverlight!
POST /PollingWcfServices/ServiceWcf.svc HTTP/1.1 Accept: */* Content-Length: 564 Content-Type: application/soap+xml; charset=utf-8 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 Host: foo Connection: Keep-Alive Pragma: no-cache Cookie: ASP.NET_SessionId=iyr4sf55rm1kypafjdvlhm55
The following polling code is used
request.onreadystatechange = function () {
if (request.readyState == 4) {
if (request.status == 200)
//Process and Poll again
else
//Handle errors
}
request.open("POST", url);
request.setRequestHeader("Content-Type", "application/soap+xml;charset=utf-8");
request.send(httpBody);
Unfortunately since the Session is set in the cookie, the server will try and process same session service calls sequentially. This is a huge problem with the long poll process. A simple solution would be to remove the Cookie from the headers, to make it look like a Silverlight poll using the silverlight client stack.
request.setRequestHeader, will only append to the header value; this doesn’t seem to make any difference since the cookie seems to be set in the head on .send.
The Mozilla only solution, found at
http://www.michael-noll.com/tutorials/cookie-monster-for-xmlhttprequest/
request.channel.loadFlags |= Ci.nsIRequest.LOAD_ANONYMOUS;
Doesn’t sem to remove the ASP.NET_SessionID cookie either. Although it does remove the ASPXAUTH cookie.
Does anyone have a solution for AJAX accessible long running service tasks not blocking sub-sequent AJAX service requests in an ASP.NET Compatibility/Sessions enabled environment?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The answer is here…
In .NET 4, you can do this in Application_BeginRequest
if (Context.Request.Path.EndsWith(“xxx.svc”))
Context.SetSessionStateBehavior(SessionStateBehavior.ReadOnly);
— How to force an IIS hosted WCF or ASMX [webservice] to use session object readonly?
By changing the SessionStateBehavior of the callback service, I was able to isolate this service to be run non-sequentially and stop the blockages.
Thanks Cine (https://stackoverflow.com/users/264022/cine)
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0