HttpWebRequest.RequestUri 屬性

定義

取得要求的原始統一資源識別元 (URI)。Gets the original Uniform Resource Identifier (URI) of the request.

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

屬性值

Uri

Uri,包含傳遞到 Create(String) 方法的網際網路資源 URI。A Uri that contains the URI of the Internet resource passed to the Create(String) method.

範例

下列程式碼範例會檢查 HttpWebRequest 物件 req 是否已重新導向至另一個位置以滿足要求,並將 hasChanged 變數的值設定為如果要求已重新導向,則為 true。否則,hasChanged 會設定為 falseThe following code example checks to see if the HttpWebRequest object req was redirected to another location to fulfill the request, and sets the value of the hasChanged variable to true if the request was redirected; otherwise, hasChanged is set to false.

bool hasChanged = req->RequestUri->Equals( req->Address );
bool hasChanged = (req.RequestUri != req.Address);
 
Dim hasChanged As Boolean = _
   (req.RequestUri.ToString() <> req.Address.ToString())

備註

WebRequest.Create的呼叫傳遞給 HttpWebRequestUri 物件。The Uri object passed to HttpWebRequest by the call to WebRequest.Create.

在重新導向標頭之後,不會變更 RequestUri 屬性。Following a redirection header does not change the RequestUri property. 若要取得回應要求的實際 URI,請檢查 Address 屬性。To get the actual URI that responded to the request, examine the Address property.

適用於