Confusion over System.Web.HttpContext.Current

So, in the server code of the silverlight application, I see several links to System.Web.HttpContext.Current.User.Identity.Name . The question arises: if System.Web.HttpContext.Current is a static property, then how are different simultaneous requests handled using different System.Web.HttpContext.Current objects?

Something is probably missing me here.

+3
source share
2 answers

Each request is served by a stream. In other words, a thread can only serve one request at a time.

Now HttpContext.Current supported by CallContext.HostContext , which is actually a stream-static property (the getter / setter property works on every thread).

Gets or sets the host context associated with the current stream.

And the way HttpContext.Current manages to always return the correct context for each request, even if several requests are served in parallel - the current thread is associated with the HttpContext, which, in turn, is associated with a specific request.

+4
source

It is static, but in the current request.

"Gets or sets the HttpContext object for the current HTTP request."

see msdn- HttpContext.Current Property

0
source

All Articles