473,396 Members | 1,774 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,396 software developers and data experts.

WebClient HTTPS Credential Problems

df
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();
Cred.UserName = "user";
Cred.Password = "pass";

WC.Credentials = Cred;

System.IO.Stream s = WC.OpenRead
("https://xxxxxx/data.html");
System.IO.StreamReader sr = new System.IO.StreamReader
(s);

string webpage = sr.ReadToEnd();
I get a 401 (unauthorized) exception, and i am 100% sure the
credentials are correct, and work perfectly in my web browser for
the file.

I have tested this code without the credentials, on a standard HTTP
URL and it works fine.

Any ideas what I am doing wrong?

Thanks
Jack
--
--------------------------------- --- -- -
Posted with NewsLeecher v3.7 Final
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Jan 6 '07 #1
3 10905
Any ideas what I am doing wrong?

Thanks
Jack
Hi Jack

If you try to use credentials you must be sure the page knows about
credentials. Are you sure you try to access page that use to login MS
Credentials ? Maybe it's just a form and you need to send your user and
password using GET/POST method?

Another them is a "cookies". You need to get cookie from site you try to
log on to and use it during all session.

cheers,
Slawomir
Jan 6 '07 #2
df
Thanks for the help, maybe I shoudnt be using credentials, when I
use the URL in my web browser i just get a standard login box pop
up, which i assumed needed credentials. The login box im refering to
is the result of .htaccess/.htpasswd files, Is there a special way
of logging into these?

Thanks again,
Jack
--
--------------------------------- --- -- -
Posted with NewsLeecher v3.7 Final
Web @ http://www.newsleecher.com/?usenet
------------------- ----- ---- -- -
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Jan 6 '07 #3
Thus wrote JackC,
Thanks for the help, maybe I shoudnt be using credentials, when I use
the URL in my web browser i just get a standard login box pop up,
which i assumed needed credentials. The login box im refering to is
the result of .htaccess/.htpasswd files, Is there a special way of
logging into these?
No, .htaccess is the NCSA style HTTP Authentication implementation (e.g.
used by Apache). Using NetworkCredential should work here.

Forms authentication on the other hand usually doesn't make use of HTTP authentication
errors, therefore I wouldn't expect to see a 401 in this case.

If all else fails, and you're able to access the file with HTTP as well,
you might want to use Fiddler or any other debugging proxy/network sniffer
to compare your application's HTTP requests to the ones sent by your browser.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Jan 7 '07 #4

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...
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");...
0
by: Kumar | last post by:
Hi all, I have the following code which uses WebClient.UploadValues myNameValueCollection.Add("Name", name) myNameValueCollection.Add("Age", age) .............. ............. Dim web As New...
0
by: Mark | last post by:
I have a very strange problem that is driving me nuts. My application is using the webclient object to send data to a webserver running on a unix box. We use 2 different environments, 1 for...
3
by: David B | last post by:
I'm looking for guidance to show developers information about implementing https using VB so that an application which needs to transfer files securely from within a VB client app can do so using...
1
by: Tedmond | last post by:
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...
4
by: gavkel | last post by:
Can anyone get this to work? All Im getting is the login html being downloaded. Would appreciate any help - my heads hurts Thanks Gav
1
by: Chad T | last post by:
I am very new to VB.Net (most of my experience is with vbscript) My goal is to create a executable to download files from a HTTPS server. I have to pass the credentials to the https server. The...
2
by: Tosco | last post by:
I read many examples with NetworkCredential and WebClient, but no one with a real http address. They all work in theory, but I wasn't able to use them in the real world. The following code should...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...
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,...

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.