Mega Code Archive

 
Categories / C# / Network
 

Gets or sets the network credentials that are sent to the host and used to authenticate the request

using System; using System.Text; using System.Net; class MainClass {     public static void Main()     {         try         {             WebClient client = new WebClient();             client.Credentials = CredentialCache.DefaultCredentials;             Byte[] pageData = client.DownloadData("http://www.google.com");             string pageHtml = Encoding.ASCII.GetString(pageData);             Console.WriteLine(pageHtml);         }         catch (WebException webEx)         {             Console.Write(webEx.ToString());         }     } }