471,088 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,088 software developers and data experts.

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
1 6185
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 Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.