AJAX访问的长时间运行的服务任务阻塞在ASP.NET兼容性能/会话环境子序贯AJAX服务请求 [英] AJAX accessible long running service tasks blocking sub-sequent AJAX service requests in an ASP.NET Compatibility/Sessions enabled environment

查看:112
本文介绍了AJAX访问的长时间运行的服务任务阻塞在ASP.NET兼容性能/会话环境子序贯AJAX服务请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在描述并在以下链接解决的问题。

I'm having a problem described and solved at the following link

<一个href=\"http://blogs.msdn.com/b/silverlightws/archive/2009/09/30/having-a-pollingduplex-service-and-any-other-wcf-service-in-the-same-website-causes-silverlight-calls-to-be-slow.aspx\" rel=\"nofollow\">http://blogs.msdn.com/b/silverlightws/archive/2009/09/30/having-a-pollingduplex-service-and-any-other-wcf-service-in-the-same-website-causes-silverlight-calls-to-be-slow.aspx

...但是我不能,因为我使用的JavaScript和Silverlight的不使用推荐的解决方案(使用客户端HTTP堆栈)!

... 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

以下轮询code使用

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);

不幸的是,因为该会议是在cookie设置,服务器将尝试过程相同的会话服务调用顺序。这是与长轮询过程一个巨大的问题。一个简单的解决办法是从头部取出饼干,使它看起来像使用Silverlight客户端堆栈一个Silverlight调查。

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,将只追加到标头值;这似乎并没有任何区别,因为该cookie似乎上的。发送头进行设置。

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.

Mozilla的唯一的解决办法,在

The Mozilla only solution, found at

HTTP://www.michael-noll .COM /教程/ cookie的怪物换xmlhtt prequest /

request.channel.loadFlags | = Ci.nsIRequest.LOAD_ANONYMOUS;

不SEM要么删除ASP.NET_SessionID的cookie。虽然它删除A​​SPXAUTH的cookie。

Doesn't sem to remove the ASP.NET_SessionID cookie either. Although it does remove the ASPXAUTH cookie.

有没有人有AJAX访问的长时间运行的服务的任务不堵在ASP.NET兼容性/会话启动环境分序贯AJAX的服务请求?解决方案

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?

推荐答案

答案就在这里...

在.NET 4中,你可以做的Application_BeginRequest这

In .NET 4, you can do this in Application_BeginRequest

如果(Context.Request.Path.EndsWith(xxx.svc))
    Context.SetSessionStateBehavior(SessionStateBehavior.ReadOnly);

if (Context.Request.Path.EndsWith("xxx.svc")) Context.SetSessionStateBehavior(SessionStateBehavior.ReadOnly);

- <一href=\"http://stackoverflow.com/questions/1269198/how-to-force-an-iis-hosted-wcf-or-asmx-webservice-to-use-session-object-readon\">How给力的IIS承载的WCF或ASMX [Web服务]以只读使用session对象?

通过改变回调服务的SessionStateBehavior,我能够隔离此服务来运行非顺序并停止堵塞。

By changing the SessionStateBehavior of the callback service, I was able to isolate this service to be run non-sequentially and stop the blockages.

感谢电影(http://stackoverflow.com/users/264022/cine)

Thanks Cine (http://stackoverflow.com/users/264022/cine)

这篇关于AJAX访问的长时间运行的服务任务阻塞在ASP.NET兼容性能/会话环境子序贯AJAX服务请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆