C# HttpWebRequest request through proxy

荒凉一梦 提交于 2019-12-06 07:22:26

few suggestions:

  1. do you use IP address for the proxy?
  2. do you need to log in to that proxy? proxy.Credentials = new NetworkCredential(User, Password);
  3. try less headers, start with few and if it works keep adding one by one

UPD: for the host - is it a valid URL? Did you put a valid port number? like www.contoso.com:8080

Try adding the following into either your web.config or app.config depending on application type:

<configuration>

    <system.net>
        <defaultProxy>
            <proxy
                usesystemdefaults="true"
                proxyaddress="http://154.46.33.157:8080"
                bypassonlocal="true" />
              <bypasslist
                <add address="[a-z]+\.contoso\.com" />
            </bypasslist>
        </defaultProxy>
    </system.net>          

     <!-- The rest of your config here ... -->

</configuration>

You can find more details and additional parameters such as user credentials etc here: http://msdn.microsoft.com/en-us/library/kd3cf2ex(v=vs.110).aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!