如何在 .NET 中为我的应用程序设置代理设置

Far*_*dan 1 .net c# proxy

我有一个 C# 应用程序,它使用服务引用通过 Web 服务发送 SMS。用户的互联网连接需要通过代理服务器才能到达世界各地。

所以我的问题是如何告诉.NET通过代理调用Web服务?或者如何为我的应用程序的互联网连接设置代理设置,就像在 YMahoo Messenger 中所做的那样?

我还想让用户选择代理设置。

sco*_*kel 5

我相信您正在寻找的内容defaultProxy在您的配置文件中

这是链接中的示例:

<configuration>
  <system.net>
    <defaultProxy>
      <proxy
        usesystemdefault="true"
        proxyaddress="http://192.168.1.10:3128"
        bypassonlocal="true"
      />
      <bypasslist>
        <add address="[a-z]+\.contoso\.com" />
      </bypasslist>
    </defaultProxy>
  </system.net>
</configuration>
Run Code Online (Sandbox Code Playgroud)