HttpWebRequest.Address Property

Definition

Gets the Uniform Resource Identifier (URI) of the Internet resource that actually responds to the request.

public Uri Address { get; }

Property Value

Uri

A Uri that identifies the Internet resource that actually responds to the request. The default is the URI used by the Create(String) method to initialize the request.

Examples

The 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 != req.Address);

Remarks

Forsiktig

WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete, and you shouldn't use them for new development. Use HttpClient instead.

The Address property is set to the URI after any redirections that happen during the request are complete.

The URI of the original request is kept in the RequestUri property.

Applies to

Produkt Versjoner
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1