Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi!
I'm trying to write a program which connects to a web site which asks for credentials and do something or read the returned data. See here [user : 'admin' pass : 'mypass'].
I'm wondering how can I do that. The programming language doesn't matter.

Thanks in advance!
Posted
Updated 8-Feb-11 8:53am
v2

1 solution

Try this example in C#:
C#
// Create a request for your URL. 		
WebRequest request = WebRequest.Create ("http://esihaj.com/phpar");
// If required by the server, set the credentials.
request.Credentials = NetworkCredential("admin", "mypass");
// Get the response.
HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
// Do something with the response you got


That should do it for you.

Cheers!
 
Share this answer
 
v2
Comments
fjdiewornncalwe 8-Feb-11 18:27pm    
I thoroughly enjoy seeing the "It needs to do something" questions. Well answered.
Manfred Rudolf Bihy 9-Feb-11 7:23am    
Thanks Marcus!
e_yasini 9-Feb-11 13:20pm    
hi
I tried it but visual studio says 401 unauthorized
Manfred Rudolf Bihy 9-Feb-11 13:33pm    
Please try with setting PreAuthenticate of request to true: request.PreAuthenticate = true;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900