Clément
Clément

Reputation: 12947

Proxy support in VB.Net

I'm running the following code to check for updates in my software, and I wonder whether VB.Net will automatically user computer proxy settings:

Dim CurrentVersion As String = (New System.Net.WebClient).DownloadString("URL/version.txt")

If not, how can I adapt it to use proxy settings?

Upvotes: 2

Views: 4465

Answers (2)

Clément
Clément

Reputation: 12947

In fact, using

Dim UpdateClient As New System.Net.WebClient
UpdateClient.Proxy = System.Net.HttpWebRequest.DefaultWebProxy
Dim CurrentVersion As String = UpdateClient.DownloadString("URL/version.txt")

is perfectly functional.

Upvotes: 1

Rowland Shaw
Rowland Shaw

Reputation: 38128

This can be done by adding the following settings to your application's app.config file:

<system.net>
    <defaultProxy useDefaultCredentials="true">
        <proxy usesystemdefault="True" />
    </defaultProxy>
</system.net>

Upvotes: 0

Related Questions