G
Guest
I am very new to VB.Net (most of my experience is with vbscript)
My goal is to create a executable to download files from a HTTPS server.
I have to pass the credentials to the https server.
The code below works fine on our IIS server configured for https but when I
connect to a remote server running "IBM_HTTP_Server/2.0.47.1-PK29827
Apache/2.0.47 (Win32) Server" The error I get is Unauthorized...
My Error: The remote server returned an error: (401) Unauthorized.
How can I fix this so it works on any https server... or is there a better
way to do this?
'************Code starts here
Imports System.IO
Imports System.Net
Imports System.Text
Module Module1
Sub Main()
Dim fullfiledownload As String
Dim filefullpath As String
Dim fileurl As String = "https://someserver/"
Dim filedownload As String = "fcs_hail_data_06.txt"
Dim newfilename As String = "Igotit.TXT"
Dim filepath As String = "C:\"
Dim userid As String = "userid"
Dim userpassword As String = "password"
fullfiledownload = fileurl & filedownload
filefullpath = filepath & newfilename
Dim wc As New WebClient
Dim myCredentials As New NetworkCredential(userid,
userpassword)
wc.Credentials = myCredentials
wc.DownloadFile(fullfiledownload, filefullpath)
End Sub
End Module
My goal is to create a executable to download files from a HTTPS server.
I have to pass the credentials to the https server.
The code below works fine on our IIS server configured for https but when I
connect to a remote server running "IBM_HTTP_Server/2.0.47.1-PK29827
Apache/2.0.47 (Win32) Server" The error I get is Unauthorized...
My Error: The remote server returned an error: (401) Unauthorized.
How can I fix this so it works on any https server... or is there a better
way to do this?
'************Code starts here
Imports System.IO
Imports System.Net
Imports System.Text
Module Module1
Sub Main()
Dim fullfiledownload As String
Dim filefullpath As String
Dim fileurl As String = "https://someserver/"
Dim filedownload As String = "fcs_hail_data_06.txt"
Dim newfilename As String = "Igotit.TXT"
Dim filepath As String = "C:\"
Dim userid As String = "userid"
Dim userpassword As String = "password"
fullfiledownload = fileurl & filedownload
filefullpath = filepath & newfilename
Dim wc As New WebClient
Dim myCredentials As New NetworkCredential(userid,
userpassword)
wc.Credentials = myCredentials
wc.DownloadFile(fullfiledownload, filefullpath)
End Sub
End Module