| 
 
 
 | 
| Keep Server Online 
 If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
 
 or
 
 
   
 A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
 
 Thank You! Steffen
 
 Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
 |  | 
 | 
| | 
| | 
|  Topic: VB.NET code Cannot Connect to Apache HTTP |  |  
| Author |  |  
| aquamusic 
 
 
 Joined: 16 Jun 2015
 Posts: 1
 
 
 | 
|  Posted: Tue 16 Jun '15 20:49    Post subject: VB.NET code Cannot Connect to Apache HTTP |   |  
| 
 |  
| Our main data supplier is changing their download server from an IBM Domino HTTP server to an IBM Apache HTTP server.  Our current working production VB.NET 4.0 code cannot access the new test Apache server, getting an error:  (401) Unauthorized. 
 I can login to the new test server in IE11 or Chrome using this format: https://extractstest.foo.org/ftp/filename/
 
 Current Code Snippet:
 
 Dim pageHtml As String
 
 Dim methodName As String = "ExtractFile.GetPageHtml: "
 
 Dim myCred As New NetworkCredential("user","password")
 
 Dim wClient As New WebClient
 
 wClient.Credentials = myCred
 
 Dim pageData As Byte() = wClient.DownloadData("https://extractstest.foo.org/ftp/filename")
 
 pageHtml = System.Text.Encoding.ASCII.GetString(pageData)
 |  |  
| Back to top |  |  
| James Blond Moderator
 
  
 Joined: 19 Jan 2006
 Posts: 7442
 Location: EU, Germany, Next to Hamburg
 
 | 
|  Posted: Wed 17 Jun '15 12:39    Post subject: |   |  
| 
 |  
| If you are using a WebClient to retrieve the file, supply it with a NetworkCredential object like so: 
 Dim wc As New WebClient() With {
 .Credentials = New NetworkCredentials("MyUserName", "MyPassword")
 }
 |  |  
| Back to top |  |  
 
 | 
 |  | 
 |  |