![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
You have to use a credential with the user name and password. I have written an example for you. I assume your apache is using "AuthType Basic" auth in the .htpasswd file public class Class1 { public Class1() { System.Console.WriteLine("Connecting to http://10.0.0.2/test"); System.Net.WebClient client = new System.Net.WebClient(); System.Net.NetworkCredential credenal = new System.Net.NetworkCredential("username", "password"); client.set_Credentials( credenal ); System.IO.Stream stream = client.OpenRead( "http://10.0.0.2/test" ); System.IO.StreamReader txt = new System.IO.StreamReader( stream ); String line; while ( (line = txt.ReadLine()) != null ) System.Console.WriteLine( line ); stream.Close(); } /** @attribute System.STAThread() */ public static void main(String[] args) { new Class1(); } } Regards, Lars-Inge Tønnessen www.larsinge.com |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |