Uredi

Deli z drugimi prek


HttpClient.DefaultRequestVersion Property

Definition

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

Property Value

The default version to use for any requests made with this HttpClient instance.

Exceptions

In a set operation, DefaultRequestVersion is null.

The HttpClient instance has already started one or more requests.

The HttpClient instance has already been disposed.

Remarks

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.

Applies to