Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# .NET:确定代理的URL_C#_Web Services_Proxy - Fatal编程技术网

C# .NET:确定代理的URL

C# .NET:确定代理的URL,c#,web-services,proxy,C#,Web Services,Proxy,我想将代理传递给我的web服务。我找到了下面的代码 MyWebService myService = new MyWebService(); System.Net.WebProxy proxyObject = new System.Net.WebProxy("http://proxyserver:80/", true); myService.Proxy = proxyObject; myService.MyMethod(); 我怎样才能得到“http://proxyserve

我想将代理传递给我的web服务。我找到了下面的代码

MyWebService myService = new MyWebService(); 
System.Net.WebProxy proxyObject = 
    new System.Net.WebProxy("http://proxyserver:80/", true); 
myService.Proxy = proxyObject;  
myService.MyMethod();
我怎样才能得到“http://proxyserver:80/“动态?

尝试以下操作:

 IWebProxy proxy = WebRequest.GetSystemWebProxy();
 proxy.Credentials = CredentialCache.DefaultCredentials;
 webRequest.Proxy = proxy;

该方法读取在Internet Explorer选项中设置的系统代理设置。如果这不是您想要的,恐怕无法自动确定某个未知代理服务器的地址。

如果用户使用无线网络怎么办connection@AMH当前位置据我所知,变化不大。无论您使用什么连接,系统代理设置都存在。我的代码只是使用了最后一个问题,请,有时用户没有选择代理,它没有被定义,它是在连接后自动设置的否,我认为它不会。用户有责任指定正确的代理设置,以便能够访问远程资源。我不确定为什么要获取“”,因为这是您知道的代理位置。你能解释一下吗?“是一个代理位置的例子,我需要动态地获取这个链接