allend2010
New member
- Joined
- Sep 5, 2003
- Messages
- 4
Hello:
I am attempting to download a file from an https site using the WebClient class. I am able to successfully plug the url with
the uid and pwd in the url from IE and it works fine. However when I use this same string from VB.Net I get an
exception:
"The underlying connection was closed: Unable to connect to the remote server."
I wasnt sure if perhaps I needed additional info for proxy settings or how to set them or if there is just something wrong
with my code.
Private Sub btnGetFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetFile.Click
Dim strURL As String = "https://myUserName:myPassword@www.theSite.com/files/all/test/"
Dim strFileSource As String = "TestTmp.Dat"
Dim strFileDestination As String = strFileSource
Dim strWebResource As String = strURL + strFileSource
Dim wc As New WebClient()
I get the same error with or without this line.
wc.Credentials = CredentialCache.DefaultCredentials
Try
wc.DownloadFile(strWebResource, strFileDestination)
Catch ex As System.Exception
lblStatus.Text = ex.Message
End Try
End Sub
Any help anybody could provide with this would be greatly apprecieated.
Thanks,
Al
I am attempting to download a file from an https site using the WebClient class. I am able to successfully plug the url with
the uid and pwd in the url from IE and it works fine. However when I use this same string from VB.Net I get an
exception:
"The underlying connection was closed: Unable to connect to the remote server."
I wasnt sure if perhaps I needed additional info for proxy settings or how to set them or if there is just something wrong
with my code.
Private Sub btnGetFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetFile.Click
Dim strURL As String = "https://myUserName:myPassword@www.theSite.com/files/all/test/"
Dim strFileSource As String = "TestTmp.Dat"
Dim strFileDestination As String = strFileSource
Dim strWebResource As String = strURL + strFileSource
Dim wc As New WebClient()
I get the same error with or without this line.
wc.Credentials = CredentialCache.DefaultCredentials
Try
wc.DownloadFile(strWebResource, strFileDestination)
Catch ex As System.Exception
lblStatus.Text = ex.Message
End Try
End Sub
Any help anybody could provide with this would be greatly apprecieated.
Thanks,
Al