NetworkCredential test

image_pdfimage_print
   



using System;
using System.Net;
using System.Text;

public class CredTest
{
   public static void Main()
   {
      WebClient wc = new WebClient();

      NetworkCredential nc = new NetworkCredential("alex", "mypassword");

      wc.Credentials = nc;

      byte[] response = wc.DownloadData("http://www.kutayzorlu.com/java2s/com/index.htm");
      Console.WriteLine(Encoding.ASCII.GetString(response));
   }
}

           
          


This entry was posted in C# Network. Bookmark the permalink.