M
Morten Snedker
I'm trying to download a file. I've tried both using webclient and the
httpWebRequest. Either way it returns a "407 proxy authentication
required".
The program is to be run externally, so basically I don't know the
users login-name, password or domain. So that makes setting the proxy
in code irrelevant, doesn't it?
When searching the web it appears to be a common problem. But I
haven't found my solution and still can't get it to work...
This the code I'm trying to execute:
'---
Function DownloadVersionFile() As Boolean
LocalVersionfile = Application.ExecutablePath
LocalVersionfile = LocalVersionfile.Substring(0,
LocalVersionfile.Length - 19) & "vk.txt"
Dim wctl As New WebClient
Try
wctl.DownloadFile(versionFile, LocalVersionfile)
DownloadVersionFile = True
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Fejl i
DownloadVersionFile")
DownloadVersionFile = False
End Try
End Function
'----
Another part of my code that fails with same error:
'---
Dim myURI As Uri, url As String
url = FileToDownload()
myURI = New Uri(url)
Try
Dim obj_HTTPWebRequest As HttpWebRequest =
CType(HttpWebRequest.Create(url), HttpWebRequest)
obj_HTTPWebRequest.Credentials =
CredentialCache.DefaultCredentials
Dim obj_HTTPWebResponse As HttpWebResponse =
obj_HTTPWebRequest.GetResponse()
lFileSize = (obj_HTTPWebResponse.ContentLength)
Catch ex As Exception
MsgBox(Err.Number)
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Fejl i
DownloadNewVersionFile")
Application.Exit()
End Try
'---
Thx in advance!
Regards /Snedker
httpWebRequest. Either way it returns a "407 proxy authentication
required".
The program is to be run externally, so basically I don't know the
users login-name, password or domain. So that makes setting the proxy
in code irrelevant, doesn't it?
When searching the web it appears to be a common problem. But I
haven't found my solution and still can't get it to work...
This the code I'm trying to execute:
'---
Function DownloadVersionFile() As Boolean
LocalVersionfile = Application.ExecutablePath
LocalVersionfile = LocalVersionfile.Substring(0,
LocalVersionfile.Length - 19) & "vk.txt"
Dim wctl As New WebClient
Try
wctl.DownloadFile(versionFile, LocalVersionfile)
DownloadVersionFile = True
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Fejl i
DownloadVersionFile")
DownloadVersionFile = False
End Try
End Function
'----
Another part of my code that fails with same error:
'---
Dim myURI As Uri, url As String
url = FileToDownload()
myURI = New Uri(url)
Try
Dim obj_HTTPWebRequest As HttpWebRequest =
CType(HttpWebRequest.Create(url), HttpWebRequest)
obj_HTTPWebRequest.Credentials =
CredentialCache.DefaultCredentials
Dim obj_HTTPWebResponse As HttpWebResponse =
obj_HTTPWebRequest.GetResponse()
lFileSize = (obj_HTTPWebResponse.ContentLength)
Catch ex As Exception
MsgBox(Err.Number)
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Fejl i
DownloadNewVersionFile")
Application.Exit()
End Try
'---
Thx in advance!
Regards /Snedker