logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: VB.NET code Cannot Connect to Apache HTTP
Author
aquamusic



Joined: 16 Jun 2015
Posts: 1

PostPosted: Tue 16 Jun '15 20:49    Post subject: VB.NET code Cannot Connect to Apache HTTP Reply with quote

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: 7371
Location: Germany, Next to Hamburg

PostPosted: Wed 17 Jun '15 12:39    Post subject: Reply with quote

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


Reply to topic   Topic: VB.NET code Cannot Connect to Apache HTTP View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner