HttpWebResponse.ResponseUri HttpWebResponse.ResponseUri HttpWebResponse.ResponseUri HttpWebResponse.ResponseUri Property

Definition

Ruft den URI der Internetressource ab, die die Anforderung beantwortet hat.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

Eigenschaftswert

Der URI der Internetressource, die die Anforderung beantwortet hat.The URI of the Internet resource that responded to the request.

Ausnahmen

Die aktuelle Instanz wurde verworfen.The current instance has been disposed.

Beispiele

In diesem Beispiel wird eine HttpWebRequest und fragt nach einer HttpWebResponse , und klicken Sie dann überprüft, ob der ursprüngliche URI vom Server umgeleitet wurde.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()

Hinweise

Die ResponseUri Eigenschaft enthält den URI der Internetressource, die letztlich auf die Anforderung geantwortet hat.The ResponseUri property contains the URI of the Internet resource that actually responded to the request. Dieser URI möglicherweise nicht identisch mit der ursprünglich angeforderten URI sein, wenn der ursprüngliche Server die Anforderung umgeleitet.This URI might not be the same as the originally requested URI, if the original server redirected the request.

Die ResponseUri Eigenschaft den Content-Location-Header verwendet wird, sofern vorhanden.The ResponseUri property will use the Content-Location header if present.

Anwendungen, die auf den letzten zugreifen müssen umgeleitet ResponseUri sollten die HttpWebRequest.Address Eigenschaft statt ResponseUri, da die Verwendung von ResponseUri Eigenschaft möglicherweise Sicherheitslücken öffnen.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.

Gilt für: