WebRequest.PreAuthenticate Özellik

Tanım

Bir alt sınıfta geçersiz kılındığında, isteğin ön kimliğinin doğrulanıp doğrulanmayacağını gösterir.

public:
 virtual property bool PreAuthenticate { bool get(); void set(bool value); };
public virtual bool PreAuthenticate { get; set; }
member this.PreAuthenticate : bool with get, set
Public Overridable Property PreAuthenticate As Boolean

Özellik Değeri

true ön kimlik doğrulaması yapmak için; aksi takdirde , false.

Özel durumlar

Özellik alt sınıfta geçersiz kılınmadığında özelliği almak veya ayarlamak için herhangi bir girişimde bulunulabilir.

Örnekler

Aşağıdaki örnek özelliği olarak true ayarlarPreAuthenticate, böylece NetworkCredential özelliğinde Credentials depolanan kaynak isteğiyle birlikte adresine gönderilir.

// Create a new webrequest to the mentioned URL.
WebRequest^ myWebRequest = WebRequest::Create( url );

// Set 'Preauthenticate' property to true. Credentials will be sent with the request.
myWebRequest->PreAuthenticate = true;

Console::WriteLine( "\nPlease enter your credentials for the requested Url" );
Console::WriteLine( "UserName" );
String^ UserName = Console::ReadLine();
Console::WriteLine( "Password" );
String^ Password = Console::ReadLine();

// Create a New 'NetworkCredential' object.
NetworkCredential^ networkCredential = gcnew NetworkCredential( UserName,Password );

// Associate the 'NetworkCredential' object with the 'WebRequest' object.
myWebRequest->Credentials = networkCredential;

// Assign the response object of 'WebRequest' to a 'WebResponse' variable.
WebResponse^ myWebResponse = myWebRequest->GetResponse();

// Create a new webrequest to the mentioned URL.
WebRequest myWebRequest=WebRequest.Create(url);

// Set 'Preauthenticate'  property to true.  Credentials will be sent with the request.
myWebRequest.PreAuthenticate=true;

Console.WriteLine("\nPlease enter your credentials for the requested Url");
Console.WriteLine("UserName");
string UserName=Console.ReadLine();
Console.WriteLine("Password");
string Password=Console.ReadLine();

// Create a New 'NetworkCredential' object.
NetworkCredential networkCredential=new NetworkCredential(UserName,Password);

// Associate the 'NetworkCredential' object with the 'WebRequest' object.
myWebRequest.Credentials=networkCredential;

// Assign the response object of 'WebRequest' to a 'WebResponse' variable.
WebResponse myWebResponse=myWebRequest.GetResponse();

' Create a new webrequest to the mentioned URL.
Dim myWebRequest As WebRequest = WebRequest.Create(url)

' Set 'Preauthenticate'  property to true.
myWebRequest.PreAuthenticate = True
Console.WriteLine(ControlChars.Cr + "Please enter your credentials for the requested Url")
Console.WriteLine("UserName")
Dim UserName As String = Console.ReadLine()
Console.WriteLine("Password")
Dim Password As String = Console.ReadLine()

' Create a New 'NetworkCredential' object.
Dim networkCredential As New NetworkCredential(UserName, Password)

' Associate the 'NetworkCredential' object with the 'WebRequest' object.
myWebRequest.Credentials = networkCredential

' Assign the response object of 'WebRequest' to a 'WebResponse' variable.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()

Açıklamalar

İlk istek dışında özelliği, PreAuthenticate sunucu tarafından istenmeyi beklemeden sonraki isteklerle kimlik doğrulama bilgilerinin gönderilip gönderilmeydiğini gösterir. olduğunda PreAuthenticatefalse, WebRequest kimlik doğrulama bilgilerini göndermeden önce kimlik doğrulaması sınamasını bekler.

Not

sınıfı WebRequest bir abstract sınıftır. Çalışma zamanında örneklerin WebRequest gerçek davranışı, yöntemi tarafından döndürülen alt sınıf tarafından WebRequest.Create belirlenir. Varsayılan değerler ve özel durumlar hakkında daha fazla bilgi için ve FileWebRequestgibi HttpWebRequest alt sınıfların belgelerine bakın.

Şunlara uygulanır

Ayrıca bkz.