473,763 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.WebC lient WC = new System.Net.WebC lient();

NetworkCredenti al Cred = new NetworkCredenti al();
Cred.UserName = "user";
Cred.Password = "pass";

WC.Credentials = Cred;

System.IO.Strea m s = WC.OpenRead
("https://xxxxxx/data.html");
System.IO.Strea mReader sr = new System.IO.Strea mReader
(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.c om<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
Jan 6 '07 #1
3 11036
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.c om<<<<<<------
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 NetworkCredenti al 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********@joer gjooss.de
Jan 7 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
15537
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...
6
11084
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 :
0
4087
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 System.Net.WebClient web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
0
1438
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 development and 1 for a staging environment. I'm using an invalid servlet name in the url deliberately in order to test my logic for basic communication problems. When I run the code against the staging box, I get a 5xx error back, which is what I...
3
1679
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 https: I'm aware the capability is available but need some guidance about where to find the detailed information so I can help a developer learn something they do not already know how to do. Any help appreciated.
1
6478
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 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
4
14286
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
9875
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 code below works fine on our IIS server configured for https but when I connect to a remote server running "IBM_HTTP_Server/2.0.47.1-PK29827 Apache/2.0.47 (Win32) Server" The error I get is Unauthorized... My Error: The remote server returned an...
2
3963
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 access an ebay page. There is no redirection involved in TestPage. If you have an ebay account you can try it in 1 minute. What's wrong with my code?
0
9386
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
9998
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
9938
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
8822
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...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5270
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...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.