进入 HttpRequestMessage 或 IHttpClientFactory 设置或连接代理
into HttpRequestMessage OR IHttpClientFactory set or connect proxy
我是初学者。放轻松我。
我想在那段代码上设置或连接代理
var requestMsg = new HttpRequestMessage(GetHttpMethod(method), url);
if (method != APIMethod.GET)
{
var serializedContent = JsonConvert.SerializeObject(request);
requestMsg.Content = new StringContent(serializedContent, Encoding.UTF8, "application/json");
}
WebProxy myproxy = new WebProxy("xxx.xx.xx.xx", 8080);
requestMsg.Proxy = myproxy; <------ error
HttpResponseMessage task = await httpClientFactory.CreateClient().SendAsync(requestMsg);
请帮我设置代理硬码
我看了这些但是我看不懂
C# Connecting Through Proxy
您可以尝试使用HttpClient.DefaultProxy设置全局Http代理。
HttpClient.DefaultProxy = new WebProxy("xxx.xx.xx.xx", 8080);
我是初学者。放轻松我。
我想在那段代码上设置或连接代理
var requestMsg = new HttpRequestMessage(GetHttpMethod(method), url);
if (method != APIMethod.GET)
{
var serializedContent = JsonConvert.SerializeObject(request);
requestMsg.Content = new StringContent(serializedContent, Encoding.UTF8, "application/json");
}
WebProxy myproxy = new WebProxy("xxx.xx.xx.xx", 8080);
requestMsg.Proxy = myproxy; <------ error
HttpResponseMessage task = await httpClientFactory.CreateClient().SendAsync(requestMsg);
请帮我设置代理硬码
我看了这些但是我看不懂
C# Connecting Through Proxy
您可以尝试使用HttpClient.DefaultProxy设置全局Http代理。
HttpClient.DefaultProxy = new WebProxy("xxx.xx.xx.xx", 8080);