How HttpContext Works in .NET

Am I trying to understand how httpcontext works in .NET?

What I cannot understand is that the HttpContext class has a static HttpContext object field. So, for each request from the client is an instance of httpcontext created or not? Why is it defined as static? Does this mean that one application can have only one httpcontext?

I'm confused, so the question that asks the question can be a bit complicated. I hope this is clear.

Thanks in advance,

+4
source share
1 answer

When you access a static member, it resolves the current query regarding the stream .

No, this does not mean that there is only one, just like Thread.Current does not mean that there is only one thread. Each request has a different HttpContext.

As a trivial way to do something like this (I don't know if this is implemented like that);

[ThreadStatic] public static string TryMeFromDifferentThreads; 
+7
source

Source: https://habr.com/ru/post/1380994/


All Articles