C# 2008 SP1
I am using the code to detect if a proxy has been set under \"Internet Options\". If there is a proxy then I will set this in my webclient.
So I
Try the following:
public string GetMeMyInfo(string searchCriteria)
{
// Instatiate the web service and declare the necessary variables
WsService.WsServiceBus oWsGetInfo = new WsService.WsServiceBus();
// Configure the Web Service Proxy
oWsGetInfo.Proxy = System.Net.WebProxy.GetDefaultProxy();
oWsGetInfo.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Invoke the web service
return oWsGetInfo.GetInfo4Me(searchCriteria);
}
That will get the default proxy setting and credentials before invoking your web service for example.
This works for me
var proxy = WebRequest.GetSystemWebProxy();
Uri testUrl = new Uri("http://proxy.example.com");
var proxyUrl = proxy.GetProxy(testUrl);
if (proxyUrl != testUrl)
//Use your proxy here
else
//We are not using a proxy