So in a server code of a silverlight app I see multiple references to System.Web.HttpContext.Current.User.Identity.Name. The question is: if System.Web.HttpContext.Current is a static property then how is it that different simultaneous requests are processed using different System.Web.HttpContext.Current objects?
I guess I’m missing something simple here.
Each request is serviced by a thread. Put another way, a thread can service only one request at a time.
Now
HttpContext.Currentis backed byCallContext.HostContext, which is effectively a thread-static property (the property getter / setter works on a per-thread basis).And that’s how
HttpContext.Currentmanages to always return the correct context for each request, even when multiple requests are being serviced in parallel – the current thread is associated with a HttpContext, which in turn is associated with a specific request.