Reputation: 13212
I know I can add the following to a client to handle a higher volume of outbound requests:
<system.net>
<connectionManagement>
<add address="*" maxconnection="65535" />
</connectionManagement>
</system.net>
Is there a way to do this in code, not in the app.config?
Upvotes: 1
Views: 639
Reputation: 14164
This should do:
Configuration config = WebConfigurationManager.OpenWebConfiguration("/YourSiteRoot");
ConnectionManagementSection connectionManagementSection =
(ConnectionManagementSection)config.GetSection("system.net/connectionManagement");
connectionManagementSection.ConnectionManagement.Add(new ConnectionManagementElement("*", 65535));
if (config.HasFile)
config.Save();
Upvotes: 1