WebClient.GetWebRequest(Uri) Method
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.
Returns a WebRequest object for the specified resource.
protected:
virtual System::Net::WebRequest ^ GetWebRequest(Uri ^ address);
protected virtual System.Net.WebRequest GetWebRequest(Uri address);
abstract member GetWebRequest : Uri -> System.Net.WebRequest
override this.GetWebRequest : Uri -> System.Net.WebRequest
Protected Overridable Function GetWebRequest (address As Uri) As WebRequest
A new WebRequest object for the specified resource.
The following code example shows an implementation of this method that can be customized by a class derived from WebClient.
virtual WebRequest^ GetWebRequest ( Uri^ address ) override
{
WebRequest^ request = dynamic_cast<WebRequest^>(WebClient::GetWebRequest( address ));
// Perform any customizations on the request.
// This version of WebClient always preauthenticates.
request->PreAuthenticate = true;
return request;
}
protected override WebRequest GetWebRequest (Uri address)
{
WebRequest request = (WebRequest) base.GetWebRequest (address);
// Perform any customizations on the request.
// This version of WebClient always preauthenticates.
request.PreAuthenticate = true;
return request;
}
Caution
WebRequest
, HttpWebRequest
, ServicePoint
, and WebClient
are obsolete, and you shouldn't use them for new development. Use HttpClient instead.
This method copies the existing Headers, Credentials, and method to the newly created WebRequest object.
This method can be called only by classes that inherit from WebClient. It is provided to give inheritors access to the underlying WebRequest object. Derived classes should call the base class implementation of GetWebRequest to ensure the method works as expected.
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 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 feedback
.NET is an open source project. Select a link to provide feedback: