I am creating a VSTO plugin in .Net Framework 4.6. I am using System.Net.Http.HttpClient for making all the API calls to server. Some of the clients are behind a proxy server and uses PAC file references in IE. The problem is with accessing the proxy(sometimes it works and sometimes it doesn't), I have added below code in my App.Config file after searching for suggestions on how to resolve the proxy related issues:
<system.net>
<defaultProxy enabled = "true" useDefaultCredentials = "true">
<proxy usesystemdefault ="True" />
</defaultProxy>
</system.net>
With the above config added in the configuration file, it works for some clients behind proxy but do not work for others behind proxy and Vice versa with config removed(some proxy works & some don't). I tried some other options by using GetDefaultProxy() and CredentialCache.DefaultCredentials with some extra calls if the earlier calls fails. But this also do not resolve the issue.
Is there a way so that I can work with both the configurations with a single installer file? Or Any other approach I should follow to solve these kind of issues? Or Is it possible that the request is not reaching to the proxy server or firewall itself with the above System.Net configuration.
Looking for some pointers in right direction or any suggestions.