I’ve the following source code:
using System.Net;
using System.Net.Http;
public class Script
{
private HttpClient _client = new HttpClient();
private WebClient _client2 = new WebClient();
}
When I test that code I got the error below:
Compiling Custom Code …
----------errors and warnings------------
Error: CS0246 - line 82 (2235) - The type or namespace name 'HttpClient' could not be found (are you missing a using directive or an assembly reference?)
So, can we use HttpClient in customization? As the MS recommendation for using HttpClient instead WebClient:
We don’t recommend that you use the
WebClient
class for new development. Instead, use the System.Net.Http.HttpClient class. (https://docs.microsoft.com/en-us/dotnet/api/system.net.webclient?view=netframework-4.7.2)