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

前端之家收集整理的这篇文章主要介绍了ASP.NET:如何处理并行请求前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
让我们在网站上有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.

猜你在找的asp.Net相关文章