creatiive
creatiive

Reputation: 1093

web service connection with WebProxy

I have a connection to a web service with an option to add proxy details. This works fine. However, it seems to fail when the proxy is not just an address, but and address with a file name... for example;

myproxy.com/proxypac.asp

It is this filename at the end that seems to be giving me issues. I am initialising my WebProxy as such;

System.Net.WebProxy wp = new System.Net.WebProxy(location.ProxyAddress, location.ProxyPort);

Can anyone offer any pointers?

Upvotes: 1

Views: 1659

Answers (1)

hoang
hoang

Reputation: 1917

Have you tried :

WebProxy proxy = new WebProxy(@"http://myproxy.com/proxypac.asp");

Or

WebProxy proxy = WebRequest.GetSystemWebProxy();

A workaround would be to open your file and check its content to see the proxy adress and port you get.

If you download your myproxy.com/proxypac.asp file it should look like this :

   function FindProxyForURL(url, host) {
      // our local URLs from the domains below example.com don't need a proxy:
      if (shExpMatch(url,"*.example.com/*")) {return "DIRECT";}
      if (shExpMatch(url, "*.example.com:*/*")) {return "DIRECT";}

      // URLs within this network are accessed through 
      // port 8080 on fastproxy.example.com:
      if (isInNet(host, "10.0.0.0",  "255.255.248.0"))    {
         return "PROXY fastproxy.example.com:8080";
      }

      // All other requests go through port 8080 of proxy.example.com.
      // should that fail to respond, go directly to the WWW:
      return "PROXY proxy.example.com:8080; DIRECT";
   }

Upvotes: 1

Related Questions