Share via


HttpWebRequest.AllowAutoRedirect Özellik

Tanım

İsteğin yeniden yönlendirme yanıtlarını izlemesi gerekip gerekmediğini belirten bir değer alır veya ayarlar.

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

Özellik Değeri

true isteğin İnternet kaynağından gelen yeniden yönlendirme yanıtlarını otomatik olarak izlemesi gerekiyorsa; aksi takdirde , false. true varsayılan değerdir.

Örnekler

Aşağıdaki kod örneği, isteğin AllowAutoRedirect yeniden yönlendirme yanıtlarını izlemesine izin vermek için özelliğini kullanır.

// Create a new HttpWebRequest Object to the mentioned URL.
HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( "http://www.contoso.com" ) );
myHttpWebRequest->MaximumAutomaticRedirections = 1;
myHttpWebRequest->AllowAutoRedirect = true;
HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() );
// Create a new HttpWebRequest Object to the mentioned URL.
HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create("http://www.contoso.com");	
myHttpWebRequest.MaximumAutomaticRedirections=1;
myHttpWebRequest.AllowAutoRedirect=true;
HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();

     'This method creates a new HttpWebRequest Object to the mentioned URL.
         Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.contoso.com"), HttpWebRequest)
         myHttpWebRequest.MaximumAutomaticRedirections = 1
         myHttpWebRequest.AllowAutoRedirect = True
         Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)

Açıklamalar

true İsteğin http yeniden yönlendirme üst bilgilerini kaynağın yeni konumuna otomatik olarak izlemesini istiyorsanız olarak ayarlayınAllowAutoRedirect. İzleyebileceğiniz en fazla yeniden yönlendirme sayısı özelliği tarafından MaximumAutomaticRedirections ayarlanır.

olarak ayarlanırsa AllowAutoRedirectfalse, http durum kodu 300 ile 399 olan tüm yanıtlar uygulamaya döndürülür.

Otomatik yeniden yönlendirmelerde Yetkilendirme üst bilgisi temizlenir ve HttpWebRequest yeniden yönlendirilen konumda otomatik olarak yeniden kimlik doğrulaması yapmaya çalışır. Uygulamada bu, yeniden yönlendirmeyle karşılaşılması mümkünse uygulamanın Yetkilendirme üst bilgisine özel kimlik doğrulama bilgileri yerleştiremediğini gösterir. Bunun yerine, uygulamanın özel bir kimlik doğrulama modülü uygulaması ve kaydetmesi gerekir. System.Net.AuthenticationManager ve ilgili sınıfı, özel bir kimlik doğrulama modülü uygulamak için kullanılır. AuthenticationManager.Register yöntemi özel bir kimlik doğrulama modülü kaydeder.

Şunlara uygulanır