467,894 Members | 1,585 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,894 developers. It's quick & easy.

Setting WebClient Credential

Dear all,

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?

Thanks for any help

Jul 6 '06 #1
  • viewed: 6026
Share:
1 Reply
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.

Jul 6 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Justin Malloy | last post: by
3 posts views Thread by Ram Baruch | last post: by
1 post views Thread by kids_pro | last post: by
1 post views Thread by Nurchi BECHED | last post: by
6 posts views Thread by Chris | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.