Thank you for your response! I've tried out in this way, but the
application does not use my proxy anyway:
public class MySettings {
public WebProxy p;
public void initializeProxySettings()
{
this.p = null;
string proxyHost = ConfigurationSettings.AppSettings["proxyHost"];
string proxyPort = ConfigurationSettings.AppSettings["proxyPort"];
string proxyUserName =
ConfigurationSettings.AppSettings["proxyUserName"];
string proxyPassword =
ConfigurationSettings.AppSettings["proxyPassword"];
ICredentials cred;
cred = new NetworkCredential(proxyUserName, proxyPassword);
p = new WebProxy(proxyHost + ":" + proxyPort, true, null, cred);
GlobalProxySelection.Select = p;
}
}
In another class, I send my webservice-request by a helper class
(CmHelper) which inherits from the class MySettings:
try {
String url = this.cmHelper.GetURL(param1,param2);
} catch (Exception e) {
System.Console.Out.WriteLine("An Exception occured
while sending the request to the CityMapService!");
System.Console.Out.WriteLine(e.Message);
System.Console.Out.WriteLine(e.StackTrace);
}
Can someone tell me what I have done wrong?
Thanks in advice!
Thomas
Peter Bromberg [C# MVP] schrieb:
Thomas,
here is some sample code to get you started:
WebProxy p = null;
string proxyAddressAndPort =
ConfigurationSettings.AppSettings["proxy"];
string proxyUserName =
ConfigurationSettings.AppSettings["proxyUserName"];
string proxyPassword =
ConfigurationSettings.AppSettings["proxyPassword"];
ICredentials cred;
cred = new NetworkCredential(proxyUserName, proxyPassword);
p = new WebProxy(proxyAddressAndPort, true, null, cred);
GlobalProxySelection.Select = p;
Hope that helps.
Peter