0

If I have a client application which needs to call a web service. I want to know the pros/cons and impact if I set default proxy property to true or false in app.config file? Thanks!

Here is the property I am talking about.

http://msdn.microsoft.com/en-us/library/kd3cf2ex.aspx

regards, George

Brann
  • 31,689
  • 32
  • 113
  • 162
George2
  • 44,761
  • 110
  • 317
  • 455

3 Answers3

1

This setting can also be setted in the machine-wide .net configuration file (If it's configured in both places, your app.config setting will prevail) Please note that you cannot set this setting if you're in a partial trust environment (so beware of click-once deployments)

That being said, if you set the setting, all http and https calls will use the default internet proxy. This doesn't concern other network connections (tcp for example), even if you've configured a socks server in the Internet Options

If there's no default proxy set, the setting has no impact, so it's usually a good idea to use it (unless you want to explicitly bypass the proxy and make a direct connection)

Brann
  • 31,689
  • 32
  • 113
  • 162
  • Thanks Brann! 1. How to find whether there is default proxy set in my computer? 2. Why "Please note that you cannot set this setting if you're in a partial trust environment (so beware of click-once deployments)"? Any more descriptions? – George2 Mar 10 '09 at 11:11
  • "so it's usually a good idea to use it " -- use it you mean set to true? – George2 Mar 10 '09 at 11:14
  • re 1 : IControl Panel/Internet Properties/Connections/LAN settings re 2 : in a Partial trust environement, you won't be able to override the system-wide default proxy settings – Brann Mar 10 '09 at 11:15
  • "won't be able to override the system-wide default proxy settings" -- you mean has no permission or not advised to do so? and Why? – George2 Mar 10 '09 at 11:22
  • In "IControl Panel/Internet Properties/Connections/LAN settings", there are a couple of settings/checkbox, which one do you mean the default proxy? – George2 Mar 10 '09 at 11:23
  • @George2 : there's an Advanced button in the 'Proxy Server' groupbox. The default proxy are in the "http" and in the "Secure" box – Brann Mar 10 '09 at 11:36
  • @George2 : I think my post is pretty clear : You can't set this setting in a partial trust environment (the .config section will be ignored, and if you try to force it you'll end up with a security exception) – Brann Mar 10 '09 at 11:37
  • Thanks Brann, if I do not select the check box -- "Use a proxy server for your LAN (These settings will not apply to dial-up or VPN connections)", does it mean there is not default proxy set? – George2 Mar 10 '09 at 12:16
  • "You can't set this setting in a partial trust environment" -- you mean I have no permision according to default group security policy? – George2 Mar 10 '09 at 12:16
  • Please see this question : http://stackoverflow.com/questions/560834/how-can-i-use-the-system-net-section-of-my-app-config-in-a-partial-trust-environm – Brann Mar 10 '09 at 12:39
  • @Brann, I want to check whether my computer configures default proxy, and if I do not select the check box -- "Use a proxy server for your LAN (These settings will not apply to dial-up or VPN connections)", does it mean there is not default proxy set? – George2 Mar 10 '09 at 13:51
  • @George2. Yes. Are you in a corporate environment or at home? – Brann Mar 10 '09 at 14:08
1

You may run into situations where there is no default proxy server but you can't connect directly, e.g. in an unattended Windows service running inside a corporate firewall, or when someone hasn't set up internet explorer. For this reason I would have the default behaviour as using the default proxy, but have a property in the config file allowing the user to override this.

The default proxy server is stored in the registry under:

HKEY_LOCAL_MACHINE\ SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Connections\WinHttpSettings
James L
  • 16,456
  • 10
  • 53
  • 70
  • Thanks TopBanana, two comments, 1. How to find whether there is default proxy set in my computer which .Net application could utilize? 2. Why you said "where there is no default proxy server" then I should "have the default proxy server set to true", seems logically conflicting? – George2 Mar 10 '09 at 11:12
1

I would personally make it a settings/options dialog in the client application so the user can either grab the default, or set their own proxy server with username and password. This way there is no room for error.

Chris S
  • 64,770
  • 52
  • 221
  • 239
  • 1
    @chris : do you have in mind a real world scenario in which the user has a default proxy set, and want to use another one for your application? – Brann Mar 10 '09 at 11:34
  • To Chris, 1. how could I find which is the default proxy? 2. Any risk of set defaultproxy to false or true? – George2 Mar 10 '09 at 12:12
  • To Brann, how to find the default proxy set on the current machine? – George2 Mar 10 '09 at 12:13
  • @George2: you seem to want a proxy to be used even when one has not been configured. Is that the case, and if so, why? – John Saunders Mar 10 '09 at 13:18
  • @George2 for specifying none domain username and passwords this is sometimes necessary, I've had to use it before – Chris S Mar 10 '09 at 13:24
  • @John, how to know whether my system is configured with a default proxy or not? – George2 Mar 10 '09 at 13:49
  • @Chris, "specifying none domain username and passwords this is sometimes necessary" -- is your comment related to my question? I did not ask username or password, :-) – George2 Mar 10 '09 at 13:50
  • Having a dialog I'd say was a pro, on the rare cases where NT authentication isn't used. Although I'm not sure how the .NET web service calls go about getting credentials if it can't find them, it might just use a dialog in which case it makes no difference and my point is void – Chris S Mar 10 '09 at 17:18