WebResponse.ResponseUri 속성

정의

파생 클래스에서 재정의될 때, 요청에 실제로 응답하는 인터넷 리소스의 URI를 가져옵니다.When overridden in a derived class, gets the URI of the Internet resource that actually responded to the request.

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

속성 값

Uri

요청에 실제로 응답하는 인터넷 리소스의 URI가 들어 있는 Uri 클래스의 인스턴스입니다.An instance of the Uri class that contains the URI of the Internet resource that actually responded to the request.

예외

속성이 서브클래스에서 재정의되지 않았는데 속성을 가져오거나 설정하려 할 경우Any attempt is made to get or set the property, when the property is not overridden in a descendant class.

예제

다음 예제에서는 합니다 ResponseUri 속성의 위치를 확인 하는 WebResponse 시작 합니다.The following example uses the ResponseUri property to determine the location from which the WebResponse originated.

Uri^ ourUri = gcnew Uri( url );

// Create a 'WebRequest' object with the specified url.
WebRequest^ myWebRequest = WebRequest::Create( url );

// Send the 'WebRequest' and wait for response.
WebResponse^ myWebResponse = myWebRequest->GetResponse();

// Use "ResponseUri" property to get the actual Uri from where the response was attained.
if ( ourUri->Equals( myWebResponse->ResponseUri ) )
{
   Console::WriteLine( "\nRequest Url : {0} was not redirected", url );
}
else
{
   Console::WriteLine( "\nRequest Url : {0} was redirected to {1}", url, myWebResponse->ResponseUri );
}

// Release resources of response object.
myWebResponse->Close();
Uri ourUri = new Uri(url);            

// Create a 'WebRequest' object with the specified url. 
WebRequest myWebRequest = WebRequest.Create(url); 

// Send the 'WebRequest' and wait for response.
WebResponse myWebResponse = myWebRequest.GetResponse(); 

// Use "ResponseUri" property to get the actual Uri from where the response was attained.
if (ourUri.Equals(myWebResponse.ResponseUri))
    Console.WriteLine("\nRequest Url : {0} was not redirected",url);   
else
    Console.WriteLine("\nRequest Url : {0} was redirected to {1}",url,myWebResponse.ResponseUri);   
// Release resources of response object.
myWebResponse.Close(); 


Dim ourUri As New Uri(url)
' Create a 'WebRequest' object with the specified url. 

Dim myWebRequest As WebRequest = WebRequest.Create(url)

' Send the 'WebRequest' and wait for response.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()

' "ResponseUri" property is used to get the actual Uri from where the response was attained.
If ourUri.Equals(myWebResponse.ResponseUri) Then
    Console.WriteLine(ControlChars.Cr + "Request Url : {0} was not redirected", url)
Else
    Console.WriteLine(ControlChars.Cr + "Request Url : {0} was redirected to {1}", url, myWebResponse.ResponseUri)
End If 

' Release resources of response object.
myWebResponse.Close()

설명

ResponseUri 실제로 응답 데이터를 제공 하는 인터넷 리소스의 URI를 포함 하는 속성입니다.The ResponseUri property contains the URI of the Internet resource that actually provided the response data. 이 리소스는 기본 프로토콜 요청의 리디렉션을 허용 하는 경우 원래 요청 된 URI 되지 않을 수 있습니다.This resource might not be the originally requested URI if the underlying protocol allows redirection of the request.

참고

합니다 WebResponse 클래스는 abstract 클래스입니다.The WebResponse class is an abstract class. 실제 동작 WebResponse 런타임 시 인스턴스 반환한 하위 클래스에 의해 결정 됩니다 WebRequest.GetResponse합니다.The actual behavior of WebResponse instances at run time is determined by the descendant class returned by WebRequest.GetResponse. 기본 값 및 예외에 대 한 자세한 내용은 참조 하십시오 하위 클래스에 대 한 설명서와 같은 HttpWebResponseFileWebResponse입니다.For more information about default values and exceptions, please see the documentation for the descendant classes, such as HttpWebResponse and FileWebResponse.

적용 대상