WebRequest.RequestUri Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bir alt sınıfta geçersiz kılındığında, istekle ilişkili İnternet kaynağının URI'sini alır.
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
Özellik Değeri
Uri İstekle ilişkili kaynağı temsil eden bir.
Özel durumlar
özelliği alt sınıfta geçersiz kılınmadığında özelliği almak veya ayarlamak için herhangi bir girişimde bulunulmaktadır.
Örnekler
Aşağıdaki örnek, başlangıçta istenen siteyi RequestUri belirlemek için özelliğini denetler.
// 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 ()
Açıklamalar
Bir alt sınıfta geçersiz kılındığında özelliği, RequestUri yöntemin UriCreate isteği oluşturmak için kullandığı örneği içerir.
Not
sınıfı WebRequest bir abstract
sınıftır. Çalışma zamanında örneklerin WebRequest gerçek davranışı, yöntemi tarafından döndürülen alt sınıf tarafından WebRequest.Create belirlenir. Varsayılan değerler ve özel durumlar hakkında daha fazla bilgi için ve FileWebRequestgibi HttpWebRequest alt sınıfların belgelerine bakın.
Uygulayanlara Notlar
RequestUriyöntemine geçirilen Create(Uri) özgün Uri örneği içermelidir. Protokol isteği hizmet vermek için isteği farklı bir URI'ye yönlendirebiliyorsa, alt öğe isteğe gerçekten hizmet veren URI'yi içeren bir özellik sağlamalıdır
Şunlara uygulanır
Ayrıca bkz.
Geri Bildirim
https://aka.ms/ContentUserFeedback.
Çok yakında: 2024 boyunca, içerik için geri bildirim mekanizması olarak GitHub Sorunları’nı kullanımdan kaldıracak ve yeni bir geri bildirim sistemiyle değiştireceğiz. Daha fazla bilgi için bkz.Gönderin ve geri bildirimi görüntüleyin