Hi,@hossein tavakoli. Welcome Microsoft Q&A.
To disable the system proxy settings for the HttpClient
in C# and bypass the VPN for the UpdateOtherAppChannel()
method, you could try to create a custom HttpClientHandler
and configure it to ignore the system proxy settings.
private void UpdateOtherAppChannel()
{
string tempImage = Path.Combine(AppContext.BaseDirectory, "tempImageEitaa.jpg");
string url = GetAPIURL("sendFile");
try
{
// Create a custom HttpClientHandler to ignore system proxy settings
HttpClientHandler httpClientHandler = new HttpClientHandler();
httpClientHandler.UseProxy = false; // Disable the system proxy settings
HttpClient client = new HttpClient(httpClientHandler);
MultipartFormDataContent content = new MultipartFormDataContent();
byte[] fileBytes = File.ReadAllBytes(tempImage);
ByteArrayContent fileContent = new ByteArrayContent(fileBytes);
content.Add(fileContent, "file", "GeneratePicture");
content.Add(new StringContent((userId.Trim().Length > 0) ? userId : ChannelId), "chat_id");
content.Add(new StringContent(caption), "caption");
HttpResponseMessage response = client.PostAsync(url, content).Result;
string responseString = response.Content.ReadAsStringAsync().Result;
}
catch (Exception ex)
{
throw;
}
}
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.