I wrote a function to use WebClient to retrieve information from the Web.
It worked fine. However, the proxy setting of our firm has been changed.
Proxy authentication is required now but I have no idea how to set the
credential for the WebClient. I went through the .Net document and only
found an example of reading credentials. Can anyone give me the idea how to
set the WebClient credential?
The way I do it is as follows:
Dim req As Net.WebRequest = Net.WebRequest.Create(New Uri(Url))
If UserName <"" And Password <"" Then
req.Credentials = New Net.NetworkCredential(UserName, Password)
End If
This code is from a vb sub that takes string inputs Url, UserName, and
Password, and it precedes calling req.GetResponse(). The code is
credential-less if UserName or Password is empty, otherwise it sets
req.Credentials in the simplest way possible. It worked for me (first try!)
on the one web site where I needed credentials. I was confused by the
documentation of this topic and I consider myself a lucky novice, so no
guarantees. Good luck.