c# - Get the value of <defaultProxy useDefaultCredentials= /> -


i want application skip logic if user had added these lines config file:

<system.net>   <defaultproxy usedefaultcredentials="true" /> </system.net> 

i thinking trick

system.net.configuration.defaultproxysection dps = new system.net.configuration.defaultproxysection(); if (!dps.usedefaultcredentials) {     //do stuff } 

but still returns false, despite config value. totally wrong in thinking here... ideas?

your code creating object fresh, not config file. instead, this:

var dps = system.configuration.configurationmanager.getsection("system.net/defaultproxy")               system.net.configuration.defaultproxysection;   if (!dps.usedefaultcredentials) {     //do stuff } 

also, want check ensure dps not null before blindly reading it's properties.


Comments