var httpclientHandler = new HttpClientHandler();
httpclientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, error) => true;
var httpClient = new HttpClient(httpclientHandler);
//注入HttpClient,并且全局禁用cookie
serviceCollection.AddHttpClient(typeof(ServiceProxy).FullName)
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
{
CookieContainer = new CookieContainer(),
UseCookies = false
});
原文:https://www.cnblogs.com/sadsadfd/p/12501283.html