How to override .NET two connections per-server limit

by admin on September 11, 2009

There’s a secret - entire .NET application connectivity is limited to 2 connections per server by default. This is a good thing to protect servers from overloading and to encourage developer consciousness, but every benefit can have a dark side as well. If you need to override this limit for some reason, you can use the following code. Don’t forget to add a reference to System.Configuration assembly in your project.

View Code CSHARP
{
System.Net.Configuration.ConnectionManagementElement managerElement = new System.Net.Configuration.ConnectionManagementElement();
managerElement.MaxConnection = 15;
System.Net.ServicePointManager.DefaultConnectionLimit = 15;
}
View Code VBNET
Dim managerElement As New System.Net.Configuration.ConnectionManagementElement
managerElement.MaxConnection = 15
System.Net.ServicePointManager.DefaultConnectionLimit = 15

Leave a Comment

Previous post: .NET Registry Tutorial

Next post: Open a specific key in regedit