The remote server returned an error: (407) Proxy Authentication Required in windows application

1.6k views Asked by At

While running below code i got "The remote server returned an error: (407) Proxy Authentication Required." issue. I did lots of RND but still facing same problem...

Code:

Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click
    Application.DoEvents()
    Dim web_client As WebClient = New WebClient
    Try
        web_client.UseDefaultCredentials = True

        web_client.DownloadFile(txtRemoteFile.Text, txtLocalFile.Text)
        MessageBox.Show("Done")

    Catch ex As Exception
        Dim wp As WebProxy
        wp = New WebProxy("ProxyIP", ProxyPort)
        wp.Credentials = New NetworkCredential("LoginName", "Password", "DomainName")
        web_client.Proxy = wp
        web_client.DownloadFile(txtRemoteFile.Text, txtLocalFile.Text)
        MessageBox.Show("Done")
    End Try

End Sub

Thanks in advance...

0

There are 0 answers