HttpClient.DefaultRequestVersion 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 or sets the default HTTP version used on subsequent requests made by this HttpClient instance.
public:
property Version ^ DefaultRequestVersion { Version ^ get(); void set(Version ^ value); };
public Version DefaultRequestVersion { get; set; }
member this.DefaultRequestVersion : Version with get, set
Public Property DefaultRequestVersion As Version
The default version to use for any requests made with this HttpClient instance.
In a set operation, DefaultRequestVersion
is null
.
The HttpClient instance has already started one or more requests.
The HttpClient instance has already been disposed.
DefaultRequestVersion
is HttpVersion.Version11 by default.
The DefaultRequestVersion
property specifies the default HTTP version to use for requests sent using this HttpClient instance when it constructs the HttpRequestMessage to send, specifically with calls to methods such as DeleteAsync, GetAsync, GetByteArrayAsync, GetStreamAsync, GetStringAsync, PatchAsync, PostAsync, and PutAsync.
The DefaultRequestVersion
property doesn't apply to the SendAsync method. The HttpRequestMessage parameter passed as the argument to the SendAsync method has its own Version
property that controls the HTTP version used for the request.
The DefaultRequestVersion
property can be changed as long as the HttpClient instance has not started any request.
Product | Versions |
---|---|
.NET | Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: