Export (0) Print
Expand All

HttpWebRequest.RequestUri Property

Gets the original URI of the request.

[Visual Basic]
Overrides Public ReadOnly Property RequestUri As Uri
[C#]
public override Uri RequestUri {get;}
[C++]
public: __property Uri* get_RequestUri();
[JScript]
public override function get RequestUri() : Uri;

Property Value

A Uri containing the URI of the Internet resource passed to the WebRequest.Create method.

Remarks

The Uri instance passed to HttpWebRequest by the call to WebRequest.Create.

Following a redirection header does not change the RequestUri property. To get the actual URI that responded to the request, examine the Address property.

Example

The following example checks to see if the HttpWebRequest instance 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.

[Visual Basic] 
Dim hasChanged As Boolean = _
   (req.RequestUri.ToString() <> req.Address.ToString())


[C#] 
bool hasChanged = (req.RequestUri != req.Address);
 

[C++] 
bool hasChanged = req->RequestUri->Equals(req->Address);
 

[JScript] 
var hasChanged : Boolean = (req.RequestUri.ToString() != req.Address.ToString())

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

HttpWebRequest Class | HttpWebRequest Members | System.Net Namespace

Show:
© 2014 Microsoft