WebRequest.RequestUri 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
서브클래스에서 재정의될 때, 요청과 연결된 인터넷 리소스의 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 요청과 연결된 리소스를 나타내는 입니다.
예외
속성이 서브클래스에서 재정의되지 않았는데 속성을 가져오거나 설정하려 할 경우
예제
다음 예제에서는 확인 합니다 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 메서드가 요청을 만드는 데 사용하는 instance Create 포함 Uri 됩니다.
참고
클래스는 WebRequest 클래스입니다 abstract
. 런타임에 인스턴스의 WebRequest 실제 동작은 메서드에서 반환된 하위 클래스에 WebRequest.Create 의해 결정됩니다. 기본값 및 예외에 대한 자세한 내용은 및 FileWebRequest와 같은 HttpWebRequest 하위 클래스에 대한 설명서를 참조하세요.
구현자 참고
RequestUri에는 메서드에 전달된 Create(Uri) 원래 Uri instance 포함되어야 합니다. 프로토콜이 요청을 다른 URI로 리디렉션하여 요청을 서비스할 수 있는 경우 하위 항목은 요청을 실제로 서비스하는 URI를 포함하는 속성을 제공해야 합니다.
적용 대상
추가 정보
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기