WebRequest.RequestUri 속성

정의

서브클래스에서 재정의될 때, 요청과 연결된 인터넷 리소스의 URI를 가져옵니다.

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

속성 값

Uri

Uri 요청과 연결된 리소스를 나타내는 형식입니다.

예외

속성이 서브클래스에서 재정의되지 않았는데 속성을 가져오거나 설정하려 할 경우

예제

다음 예제에서는 속성을 확인 RequestUri 하여 원래 요청된 사이트를 확인합니다.

// Create a new WebRequest object to the mentioned URL.
WebRequest^ myWebRequest = WebRequest::Create( "http://www.contoso.com" );
Console::WriteLine( "\nThe Uri requested is {0}", myWebRequest->RequestUri);
// Assign the response object of 'WebRequest' to a 'WebResponse' variable.
WebResponse^ myWebResponse = myWebRequest->GetResponse();
      // Get the stream containing content returned by the server.
Stream^ streamResponse = myWebResponse->GetResponseStream();
      Console::WriteLine("\nThe Uri that responded to the request is '{0}'",myWebResponse->ResponseUri);
StreamReader^ reader = gcnew StreamReader(streamResponse);
      // Read the content.
String^ responseFromServer = reader->ReadToEnd();
// Display the content.
Console::WriteLine("\nThe HTML Contents received:");
Console::WriteLine (responseFromServer);
// Cleanup the streams and the response.
reader->Close();
streamResponse->Close();
myWebResponse->Close();
      // Create a new WebRequest Object to the mentioned URL.
      WebRequest myWebRequest=WebRequest.Create("http://www.contoso.com");
      Console.WriteLine("\nThe Uri that was requested is {0}",myWebRequest.RequestUri);
      // Assign the response object of 'WebRequest' to a 'WebResponse' variable.
      WebResponse myWebResponse=myWebRequest.GetResponse();
      // Get the stream containing content returned by the server.
      Stream streamResponse=myWebResponse.GetResponseStream();
      Console.WriteLine("\nThe Uri that responded to the WebRequest is '{0}'",myWebResponse.ResponseUri);
StreamReader reader = new StreamReader (streamResponse);
      // Read the content.
string responseFromServer = reader.ReadToEnd ();
// Display the content.
Console.WriteLine("\nThe HTML Contents received:");
Console.WriteLine (responseFromServer);
// Cleanup the streams and the response.
reader.Close ();
streamResponse.Close ();
myWebResponse.Close ();
' Create a new WebRequest Object to the mentioned URL.
Dim myWebRequest As WebRequest = WebRequest.Create("http://www.contoso.com")
Console.WriteLine(ControlChars.Cr + ControlChars.Lf +"The Uri that was requested is {0}", myWebRequest.RequestUri)
' Assign the response object of 'WebRequest' to a 'WebResponse' variable.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
      ' Get the stream containing content returned by the server.
Dim streamResponse As Stream = myWebResponse.GetResponseStream()
Console.WriteLine(ControlChars.Cr + ControlChars.Lf + "The Uri that responded to the request is {0}", myWebResponse.ResponseUri)
' Print the HTML contents of the page to the console. 
Dim reader As New StreamReader(streamResponse)
      ' Read the content.
      Dim responseFRomServer As String = reader.ReadToEnd()
' Display the content.
Console.WriteLine(ControlChars.Cr + ControlChars.Lf +"The HTML Contents received:")
Console.WriteLine (responseFromServer)
' Cleanup the streams and the response.
reader.Close ()
streamResponse.Close ()
myWebResponse.Close ()

설명

하위 클래스 RequestUri 에서 재정의되는 경우 이 속성에는 Uri 메서드가 Create 요청을 만드는 데 사용하는 인스턴스가 포함됩니다.

참고

WebRequest 클래스는 클래스입니다abstract. 런타임에 인스턴스의 WebRequest 실제 동작은 메서드에서 반환된 하위 클래스에 의해 WebRequest.Create 결정됩니다. 기본값 및 예외에 대한 자세한 내용은 하위 클래스(예 HttpWebRequest : 및 FileWebRequest)에 대한 설명서를 참조하세요.

구현자 참고

RequestUri 는 메서드에 전달된 원래 Uri 인스턴스를 Create(Uri) 포함해야 합니다. 프로토콜이 요청을 다른 URI로 리디렉션하여 요청을 처리할 수 있는 경우 하위 항목은 요청을 실제로 서비스하는 URI를 포함하는 속성을 제공해야 합니다.

적용 대상

추가 정보