Does every 'HttpRequest' get its own threa

2019-02-05 15:39发布

问题:

In ASP.NET, does every HttpRequest get its own thread?

Update - To clarify, I'm asking specifically about incoming requests.

回答1:

If you're referring to using the HttpRequest object for making outgoing requests from your application, no - HttpRequest runs in the current thread.

If you're referring to how IIS and ASP.NET handles threading per request, yes. Each request is run on a separate thread. However, the model is a little more complex than that - there are worker threads and I/O threads to consider. And under load, .NET will sometimes move requests from one thread to another as it sees fit. This is important to understand when dealing with things like ThreadStatic.