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 DownloadVersion File() As Boolean
LocalVersionfil e = Application.Exe cutablePath
LocalVersionfil e = LocalVersionfil e.Substring(0,
LocalVersionfil e.Length - 19) & "vk.txt"
Dim wctl As New WebClient
Try
wctl.DownloadFi le(versionFile, LocalVersionfil e)
DownloadVersion File = True
Catch ex As Exception
MsgBox(ex.Messa ge, MsgBoxStyle.Exc lamation, "Fejl i
DownloadVersion File")
DownloadVersion File = 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_HTTPWebRequ est As HttpWebRequest =
CType(HttpWebRe quest.Create(ur l), HttpWebRequest)
obj_HTTPWebRequ est.Credentials =
CredentialCache .DefaultCredent ials
Dim obj_HTTPWebResp onse As HttpWebResponse =
obj_HTTPWebRequ est.GetResponse ()
lFileSize = (obj_HTTPWebRes ponse.ContentLe ngth)
Catch ex As Exception
MsgBox(Err.Numb er)
MsgBox(ex.Messa ge, MsgBoxStyle.Exc lamation, "Fejl i
DownloadNewVers ionFile")
Application.Exi t()
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 DownloadVersion File() As Boolean
LocalVersionfil e = Application.Exe cutablePath
LocalVersionfil e = LocalVersionfil e.Substring(0,
LocalVersionfil e.Length - 19) & "vk.txt"
Dim wctl As New WebClient
Try
wctl.DownloadFi le(versionFile, LocalVersionfil e)
DownloadVersion File = True
Catch ex As Exception
MsgBox(ex.Messa ge, MsgBoxStyle.Exc lamation, "Fejl i
DownloadVersion File")
DownloadVersion File = 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_HTTPWebRequ est As HttpWebRequest =
CType(HttpWebRe quest.Create(ur l), HttpWebRequest)
obj_HTTPWebRequ est.Credentials =
CredentialCache .DefaultCredent ials
Dim obj_HTTPWebResp onse As HttpWebResponse =
obj_HTTPWebRequ est.GetResponse ()
lFileSize = (obj_HTTPWebRes ponse.ContentLe ngth)
Catch ex As Exception
MsgBox(Err.Numb er)
MsgBox(ex.Messa ge, MsgBoxStyle.Exc lamation, "Fejl i
DownloadNewVers ionFile")
Application.Exi t()
End Try
'---
Thx in advance!
Regards /Snedker
Comment