Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET client app: how to reach Web Services in case of proxy?

We are developing a .NET 2.0 winform application. The application needs to access Web Services. Yet, we are encountering issues with users behind proxies.

Popular windows backup applications (think Mozy) are providing a moderately complex dialog window dedicated the proxy settings. Yet, re-implementing yet-another proxy handling logic and GUI looks a total waste of time to me.

What are best ways to deal with proxy with .NET client apps?

More specifically, we have a case where the user has recorded his proxy settings in Internet Explorer (including username and password), so the default proxy behavior of .NET should work. Yet, the user is still prompted for his username and password when launching IE (both fields are pre-completed, the user just need to click OK) - and our winform application still fails at handling the proxy.

What should we do to enforce that the user is not prompted for his username and password when launching IE?

like image 476
Joannes Vermorel Avatar asked Dec 14 '22 06:12

Joannes Vermorel


2 Answers

Put this in your application's config file:

<configuration>
  <system.net>
    <defaultProxy>
      <proxy autoDetect="true" />
    </defaultProxy>
  </system.net>
</configuration>

and your application will use the proxy settings from IE. If you can see your web service in IE using the proxy server, you should be able to "see" it from your application.

like image 148
MusiGenesis Avatar answered Feb 19 '23 13:02

MusiGenesis


Use WebProxy and WebRequest classes. Wrap it into you own library just for one time and use everywhere you want work with proxy.

like image 32
Vokinneberg Avatar answered Feb 19 '23 15:02

Vokinneberg