blue18hutthutt
blue18hutthutt

Reputation: 3243

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

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

Upvotes: 10

Views: 4453

Answers (2)

alex.net
alex.net

Reputation: 286

HttpContext.Items is stateless the only way to "share" between requests is Session or higher level state (database)

Upvotes: 2

Juned Ahsan
Juned Ahsan

Reputation: 68715

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

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

Upvotes: 10

Related Questions