Reputation: 9255
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?
Upvotes: 4
Views: 2793
Reputation: 21722
I think the asker understands he has to use WebProxy if the user requires a proxy, the question is "how do I get IE's proxy settings so I don't have to ask the user to type them in to my app as well?"
System.Net.WebProxy.GetDefaultProxy is obsolete, you have to use System.Net.WebRequest.DefaultWebProxy. There is an article describing it at http://msdn.microsoft.com/en-ca/magazine/cc300743.aspx.
Upvotes: 0
Reputation: 75386
Are your clients that are experiencing proxy problems all on the same network (i.e. are they all using the same proxy server)?
Upvotes: 0
Reputation: 75386
If you open IE, click OK to the proxy dialog, and then (leaving IE open) try to connect with your winforms app, does your app then work? Or does your app fail to handle the proxy no matter what?
Upvotes: 0
Reputation: 75386
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.
Upvotes: 10
Reputation: 2017
Use WebProxy and WebRequest classes. Wrap it into you own library just for one time and use everywhere you want work with proxy.
Upvotes: 2
Reputation: 1556
Look into using the .NET WebProxy class. It has support for automatically selecting the correct default settings.
Upvotes: 1
Reputation: 7559
The easiest way is to use the proxy settings from IE Explorer.
Upvotes: 0