HttpWebRequest.Address Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the Uniform Resource Identifier (URI) of the Internet resource that actually responds to the request.
public:
property Uri ^ Address { Uri ^ get(); };
public Uri Address { get; }
member this.Address : Uri
Public ReadOnly Property Address As 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.
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->Equals( req->Address );
bool hasChanged = (req.RequestUri != req.Address);
Dim hasChanged As Boolean = _
(req.RequestUri.ToString() <> req.Address.ToString())
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.
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 |
.NET-tilbakemelding
.NET er et åpen kilde-prosjekt. Velg en kobling for å gi tilbakemelding: