我想在ASP.NET Web窗体中使用.NET 4.5 HttpClient类。 我在C#5.0简而言之图书阅读(页663):在ASP.NET Web窗体中使用.NET 4.5 HttpClient
Unlike with WebClient, to get the best performance with HttpClient, you must reuse same instance (otherwise things such as DNS resolution may be unnecessarily repeated.) HttpClient permits concurrent operations, . . .
在我们的ASP.NET Web窗体的网站,我们需要连接到其他网站。 我在应用程序属性中创建了一个HttpClient实例,以在所有请求中使用单个实例。在Global.asax中这样的事情 写的是:
Application.Add("MateCatWorker", new HttpClient());
我的问题是:这是一个好的做法呢?
你为什么认为这不是好的做法? –
因为:当我按照上述惯例推出我们的网站时,我遇到了来自客户的两种错误,我不明白为什么。 –
那么你试图修复它?另外,仅仅因为某些事情不起作用并不意味着它不是最佳实践,它可能只是实践的一个不好的实施。 –