Indicates whether to pre-authenticate the request.
using System;
using System.Net;
using System.IO;
using System.Text;
using System.Threading;
public class MainClass
{
public static void Main()
{
Uri url = new Uri("http://www.google.com");
WebRequest myWebRequest = WebRequest.Create(url);
myWebRequest.PreAuthenticate = true;
string UserName = "Tom";
string Password = "password";
NetworkCredential networkCredential = new NetworkCredential(UserName, Password);
myWebRequest.Credentials = networkCredential;
WebResponse myWebResponse = myWebRequest.GetResponse();
}
}
Related examples in the same category