加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

ASP.NET:如何处理并行请求

发布时间:2020-12-16 00:13:00 所属栏目:asp.Net 来源:网络整理
导读:让我们在网站上有2页成像:快速和慢速.慢速页面请求执行1分钟,请求快速5秒. 整个我的开发生涯我认为如果第一次启动请求很慢:他将对DB进行(同步)调用…等待回答…如果在此期间请求快速页面将完成,此请求将被处理系统正在等待DB的响应. 但今天我发现: http:/
让我们在网站上有2页成像:快速和慢速.慢速页面请求执行1分钟,请求快速5秒.

整个我的开发生涯我认为如果第一次启动请求很慢:他将对DB进行(同步)调用…等待回答…如果在此期间请求快速页面将完成,此请求将被处理系统正在等待DB的响应.

但今天我发现:
http://msdn.microsoft.com/en-us/library/system.web.httpapplication.aspx

One instance of the HttpApplication class is used to process many requests in its lifetime. However,it can process only one request at a time. Thus,member variables can be used to store per-request data.

这是否意味着我原来的想法是错的?

你能澄清一下他们的意思吗?我很确定这件事是我所期待的……

解决方法

如果两个请求都使用具有读/写访问权限的相同会话状态,则必须在服务器端按顺序处理请求,因为asp.net会话锁定.

您可以在这里找到更多信息:
http://msdn.microsoft.com/en-us/library/ie/ms178581.aspx

Concurrent Requests and Session State

Access to ASP.NET session state is exclusive per session,which means that if two different users make concurrent requests,access to each separate session is granted concurrently. However,if two concurrent requests are made for the same session (by using the same SessionID value),the first request gets exclusive access to the session information. The second request executes only after the first request is finished. (The second session can also get access if the exclusive lock on the information is freed because the first request exceeds the lock time-out.) If the EnableSessionState value in the @ Page directive is set to ReadOnly,a request for the read-only session information does not result in an exclusive lock on the session data. However,read-only requests for session data might still have to wait for a lock set by a read-write request for session data to clear.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读