在异步设计会议 [英] Sessions in Asynchronous design

查看:180
本文介绍了在异步设计会议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在建立一个支持AJAX的Web应用程序,使多个异步请求给服务器。每个服务器的请求是每一个JSON对象返回返回HTML页面长时间运行的服务器任务。每个电话都需要读/写访问会话对象。

We are building a AJAX enabled web application that makes multiple asynchronous requests to the server. Each of these server requests are long running server tasks with each returning back a JSON object to the html page. Each of these calls need read/write access to the Session object.

但ASP.NET锁定会话对象时,多个异步任务的过程中,从而阻断了第一个异步调用。因此,这些异步调用永远不会发生在平行。

But the ASP.NET locks the session object when multiple asynchronous tasks are in process, thus blocking the first asynchronous call. So these asynchronous calls never happen in parallel.

PS:异步调用是PageMethod的电话

PS: The asynchronous calls are PageMethod calls.

在会话都'不是'建议首先使用时沿端异步调用。在设计这个异步请求模型中的任何其他的建议将是非常美联社preciated。

Are Sessions are 'not' recommended in the first place when used along-side asynchronous calls. Any other suggestions on designing this asynchronous request model will be highly appreciated.

推荐答案

感谢大家公布答案和意见,我的问题。我总结我的研究结果和解决方案,从而使他人可能会发现这很有用。

Thanks to everyone that posted answers and comments to my question. I'm summing up my findings and solution so that someone may find this useful.

每个人的评论是正确的有关建议不要使用会话的异步调用。所以,我怎么会围绕它得到什么呢?

Everyone that commented is correct about recommending not to use Sessions in asynchronous calls. So, how did I get around it?

  1. 改变PageMethod的呼叫到一个HttpHandler的实施IReadOnlySessionState。 (在我的情况下,Ajax调用只需要读访问到Session对象)
  2. 客户端jQuery让Ajax调用到服务器的HttpHandler
  3. 在@Page的EnableSessionState指令可以保留为默认值(读/写)

使用上述溶液中,多个异步调用是可能与每个呼叫读入会话对象

With the above solution, multiple async calls are possible with each call reading into the session object

有关制作一个jQuery调用一个HTTP处理程序返回一个JSON对象的详细信息,这里的<一个href="http://www.sharepointnutsandbolts.com/2010/11/sp2010-ajax-part-3-using-jquery-ajax.html">link

For more information about making a Jquery call to a HTTP Handler returning a JSON object, here's the link

这篇关于在异步设计会议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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