For diagnostics purposes I am logging ServicePointManager.DefaultConnectionLimit. However oddly enough it seems to be returning Int32.MaxValue (i.e 2147483647).
This
Based on @Wimmel's link it seems in ASP.Net that it is set to Int32.MaxValue
as part of the HTTP Runtime.
We can see this by looking inside the System.Web assembly at the HttpRuntime class.
There is a method called SetAutoConfigLimits
which sets it to Int32.MaxValue
.
Here is the relevant excerpt:
private void SetAutoConfigLimits(ProcessModelSection pmConfig)
{
int workerThreads;
int completionPortThreads;
ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads);
if (pmConfig.DefaultMaxWorkerThreadsForAutoConfig != workerThreads || pmConfig.DefaultMaxIoThreadsForAutoConfig != completionPortThreads)
UnsafeNativeMethods.SetClrThreadPoolLimits(pmConfig.DefaultMaxWorkerThreadsForAutoConfig, pmConfig.DefaultMaxIoThreadsForAutoConfig, true);
ServicePointManager.DefaultConnectionLimit = int.MaxValue;
}