HttpWebResponse.ResponseUri Özellik

Tanım

İsteğe yanıt veren Internet kaynağının URI 'sini alır.Gets the URI of the Internet resource that responded to the request.

public:
 virtual property Uri ^ ResponseUri { Uri ^ get(); };
public override Uri ResponseUri { get; }
member this.ResponseUri : Uri
Public Overrides ReadOnly Property ResponseUri As Uri

Özellik Değeri

Uri

İsteğe yanıt veren Internet kaynağının URI 'SI.The URI of the Internet resource that responded to the request.

Özel durumlar

Geçerli örnek atıldı.The current instance has been disposed.

Örnekler

Bu örnek, HttpWebRequest için bir ve sorguları oluşturur HttpWebResponse ve ardından özgün URI 'nin sunucu tarafından yeniden yönlendirilip yönlendirilmediğini denetler.This example creates a HttpWebRequest and queries for an HttpWebResponse and then checks to see whether the original URI was redirected by the server.

Uri^ myUri = gcnew Uri( url );
// Create a 'HttpWebRequest' object for the specified url.
HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)( WebRequest::Create( myUri ) );
// Send the request and wait for response.
HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)( myHttpWebRequest->GetResponse() );
if ( myHttpWebResponse->StatusCode == HttpStatusCode::OK )
{
   Console::WriteLine( "\nRequest succeeded and the requested information is in the response , Description : {0}",
      myHttpWebResponse->StatusDescription );
}
if ( myUri->Equals( myHttpWebResponse->ResponseUri ) )
{
   Console::WriteLine( "\nThe Request Uri was not redirected by the server" );
}
else
{
   Console::WriteLine( "\nThe Request Uri was redirected to : {0}", myHttpWebResponse->ResponseUri );
}
// Release resources of response Object*.
myHttpWebResponse->Close();
Uri myUri = new Uri(url);
// Create a 'HttpWebRequest' object for the specified url.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(myUri);
// Send the request and wait for response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
if (myHttpWebResponse.StatusCode == HttpStatusCode.OK)
    Console.WriteLine("\nRequest succeeded and the requested information is in the response ,Description : {0}",
                        myHttpWebResponse.StatusDescription);
if (myUri.Equals(myHttpWebResponse.ResponseUri))
    Console.WriteLine("\nThe Request Uri was not redirected by the server");
else
    Console.WriteLine("\nThe Request Uri was redirected to :{0}",myHttpWebResponse.ResponseUri);
// Release resources of response object.
myHttpWebResponse.Close();
Dim myUri As New Uri(url)
' Create a 'HttpWebRequest' object for the specified url 
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(myUri), HttpWebRequest)
' Send the request and wait for response.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
If myHttpWebResponse.StatusCode = HttpStatusCode.OK Then
    Console.WriteLine(ControlChars.Cr + "Request succeeded and the requested information is in the response , Description : {0}", myHttpWebResponse.StatusDescription)
End If
If myUri.Equals(myHttpWebResponse.ResponseUri) Then
    Console.WriteLine(ControlChars.Cr + "The Request Uri was not redirected by the server")
Else
    Console.WriteLine(ControlChars.Cr + "The Request Uri was redirected to :{0}", myHttpWebResponse.ResponseUri)
End If
' Release resources of response object.
myHttpWebResponse.Close()

Açıklamalar

ResponseUriÖzelliği, isteğe gerçekten yanıt veren Internet KAYNAĞıNıN URI 'sini içerir.The ResponseUri property contains the URI of the Internet resource that actually responded to the request. Özgün sunucu isteği yeniden yönlendirirse, bu URI, ilk olarak istenen URI ile aynı olmayabilir.This URI might not be the same as the originally requested URI, if the original server redirected the request.

Özelliği varsa, ResponseUri Içerik konumu üst bilgisini kullanır.The ResponseUri property will use the Content-Location header if present.

ResponseUri HttpWebRequest.Address ResponseUri ResponseUri Özelliğin kullanılması güvenlik açıklarını açabildiğinden, en son yeniden yönlendirilen uygulamalar yerine özelliği kullanmalıdır.Applications that need to access the last redirected ResponseUri should use the HttpWebRequest.Address property rather than ResponseUri, since the use of ResponseUri property may open security vulnerabilities.

Şunlara uygulanır