473,421 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 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 6422
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Justin Malloy | last post by:
I am using the System.Net.Webclient to try and download an XML file from a website but am receiving a HTTP protocol error when running the DownloadFile() sub routine. I did a HTTP trace using...
3
by: Ram Baruch | last post by:
Hi, I'm trying to use WebClient class to upload data. In order to upload it, I need to use my username and password. Does somebody know how can I set it in the WebClient class? Regards, Ram.
1
by: kids_pro | last post by:
My application need to request data from linux web server. The web server required a valid username and password before it pass back the data. How can I achieve this goal using webclient? If it...
1
by: Nurchi BECHED | last post by:
Hello, everyone. I am stuck with the following: There is a webpage which contains a webform, which contains text fields, and submits the data from current page to another one. I need to...
6
by: Chris | last post by:
Hi, I try to download a file using the following : WebClient client = new WebClient(); client.Credentials = new NetworkCredential("Administrator", "test","MYPC");...
1
by: Mad Scientist Jr | last post by:
For some reason I can't get a WebClient to access an outside URL from behind our firewall. The code works when it runs outside the firewall. I turned on windows authentication in the web.config...
3
by: df | last post by:
Hi, I'm trying to download the web page source code from a HTTPS URL, my code is as follows: Code: System.Net.WebClient WC = new System.Net.WebClient(); NetworkCredential Cred = new...
1
by: Mike | last post by:
I am using PowerShell to download an XML file into a string using the DownloadString(URI) method of System.Net.WebClient object. Sample commands below: $Result = $Null; $WebClient = new-object...
2
by: MichaelSchoeler | last post by:
Hi, I'm having problems with the WebClient class regarding UTF-8 encoded data. When I access a specific webservice directly I can see the data arrives in corretly formatted UTF-8. But when I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.