是HttpContext.Current.Items线程安全的请求之间? [英] Is HttpContext.Current.Items thread-safe between Requests?

查看:368
本文介绍了是HttpContext.Current.Items线程安全的请求之间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设人有一个处理每个请求一个HttpHandler,并假设每一个HttpHandler的计算的中间结果为每个请求,并可能想通过这一个页面处理程序通过HttpContext.Items集合<通过Server.Transfer的或使用Server.Execute如/ P>

将每个请求都HttpContext.Items的单独副本[sameKey当他们各自达到相同的.aspx页面?

我关心的事实HttpContext.Current本身就是一个静态属性发生

解决方案
  

的HttpContext 封装有关个别HTTP所有HTTP特定的信息   请求。

因此​​,每个请求HttpContext.Items [sameKey]将是一个不同的副本。

Suppose one has an HttpHandler that processes each request, and suppose each HttpHandler computes an intermediate result for each request and potentially wants to pass this to a page handler eg via Server.Transfer or Server.Execute via the HttpContext.Items collection

Will each request have a separate copy of HttpContext.Items["sameKey"] when they each reach the same .aspx page?

My concern arises from the fact HttpContext.Current is itself a static property

解决方案

HttpContext Encapsulates all HTTP-specific information about an individual HTTP request.

Hence each request HttpContext.Items["sameKey"] will be a different copy.

这篇关于是HttpContext.Current.Items线程安全的请求之间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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