.net核心中的ServicePointManager.DefaultConnectionLimit?

时间:2016-04-04 09:04:50

标签: .net asp.net-core asp.net-core-mvc dnx coreclr

我正在将.net api 2服务移植到.net核心,我在旧的web api服务中找到了这一行。

ServicePointManager.DefaultConnectionLimit = int.MaxValue;

此代码行增加了连接限制。我不知道它是针对计算机,框架还是应用程序。在阅读了stackoverflow上的this回答后,我也意识到将其设置为int.max可能不是最好的主意。但是,我仍然想在我的新.net核心服务中控制它。

如何在.net核心中修改/增加DefaultConnectionLimit。另外,我怎么知道.net核心的默认限制是什么? (如果这是一个有效的问题:))

1 个答案:

答案 0 :(得分:8)

在ASP.NET 5应用中,使用WinHttpHandler.MaxConnectionsPerServer。其默认值为int.MaxValue

有关详细信息,请参阅.NET Portability Analyzer from the Visual Studio GalleryWinHttpHandler.MaxConnectionsPerServer on MSDN

What to do in ASP.NET 5 apps...