Last active
March 31, 2021 07:49
-
-
Save PatrickMcDonald/7116690 to your computer and use it in GitHub Desktop.
Tell .NET application to use default proxy configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = new System.Net.WebClient(); | |
client.Proxy = System.Net.WebRequest.DefaultWebProxy; | |
client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials; | |
client.DownloadFile(Address, FileName); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration> | |
<system.net> | |
<defaultProxy useDefaultCredentials="true" /> | |
</system.net> | |
</configuration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let downloadFile (url:string) targetPath = | |
let wc = new Net.WebClient() | |
wc.Proxy <- System.Net.WebRequest.DefaultWebProxy; | |
wc.Proxy.Credentials <- System.Net.CredentialCache.DefaultCredentials | |
wc.DownloadFile(url, targetPath) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials | |
# or | |
$webClient = New-Object System.Net.WebClient | |
$webClient.Proxy = [System.Net.WebRequest]::DefaultWebProxy; | |
$webClient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment