How to authenticate against a proxy when using the HttpClient class?

前端 未结 2 2044
有刺的猬
有刺的猬 2020-12-02 21:25

I have a console app built on .NET 4 that uses the HttpClient library (obtained via NuGet) to retrieve data from a public API over the internet. The console app

2条回答
  •  执笔经年
    2020-12-02 21:58

    If you wanted to do the same programmatically you could use the following:

    WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
    

    (These objects are from the `System.Net' namespace).

    Some more info from MSDN: http://msdn.microsoft.com/en-us/library/system.net.webproxy.getdefaultproxy.aspx

提交回复
热议问题