Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is HttpContext.Current.Items thread-safe between Requests?

Tags:

c#

.net

asp.net

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

like image 725
blue18hutthutt Avatar asked Jun 23 '13 14:06

blue18hutthutt


1 Answers

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

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

like image 151
Juned Ahsan Avatar answered Oct 12 '22 17:10

Juned Ahsan