473,748 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6476
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.NetworkCred ential(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
15528
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 internet explorer to see what is happening in the request and it looks as though the request originates using HTTP/1.1 to an IIS server authenticates itself but ultimately gets executed by a Java Application server and when the request is fulfilled...
3
67668
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
4362
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 possible to pass authentication header using webclient class? Regards, Kids
1
2608
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 submit the same data to a webpage from a Windows Form.
6
11073
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"); client.DownloadFile("http://localhost/afile.txt", "c:\\test.txt"); but I get an error :
1
6496
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 <authentication mode="Windows" /> and set up IIS to not allow anonymous access. My browser is set up to auto detect the proxy server, so IE/Firefox can access outside pages, so I added code to auto-detect the proxy server.
3
11031
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 NetworkCredential();
1
12496
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 System.Net.WebClient; $WebClient.Encoding = ::Default; $WebClient.Proxy = ::DefaultWebProxy; $WebClient.Proxy.Credentials = ::DefaultCredentials;
2
10171
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 try to pull data from the same webservice url through the WebClient class I get partly garbled UTF-8 data in return. Only some UTF-8 chars (double byte pairs) seems to be corrupted. // Does not work WebClient wc = new WebClient(); string...
0
8987
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9534
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9366
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8239
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6073
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.