我知道我可以将以下内容添加到客户端以处理更多的出站请求:
<system.net>
<connectionManagement>
<add address="*" maxconnection="65535" />
</connectionManagement>
</system.net>
有没有办法在代码中执行此操作,而不是在app.config中执行此操作?
答案 0 :(得分:1)
这应该做:
Configuration config = WebConfigurationManager.OpenWebConfiguration("/YourSiteRoot");
ConnectionManagementSection connectionManagementSection =
(ConnectionManagementSection)config.GetSection("system.net/connectionManagement");
connectionManagementSection.ConnectionManagement.Add(new ConnectionManagementElement("*", 65535));
if (config.HasFile)
config.Save();