HttpRequestMessage.Version 属性

定义

获取或设置 HTTP 消息版本。Gets or sets the HTTP message version.

public:
 property Version ^ Version { Version ^ get(); void set(Version ^ value); };
public Version Version { get; set; }
member this.Version : Version with get, set
Public Property Version As Version

属性值

HTTP 消息版本。The HTTP message version. 默认值为1.1,除非你面向的是 .net Core 2.1 或2.2。The default value is 1.1, unless you're targeting .NET Core 2.1 or 2.2. 在这种情况下,默认值为2.0In that case, the default value is 2.0.

注解

在 .NET Core 中,默认消息版本因您使用的版本而异。In .NET Core, the default message version differs based on the version you're using. .NET Core 2.1 将默认值从 1.1 更改为 2.0.NET Core 2.1 changed the default value from 1.1 to 2.0. 在 .NET Core 3.0 中,默认值已恢复为 1.1In .NET Core 3.0, the default value was reverted back to 1.1.

.NET Framework.NET Framework

默认消息版本为 1.1The default message version is 1.1.

.NET Core.NET Core

下表列出了基于 .NET Core 版本的默认消息版本:The following table lists the default message version based on the version of .NET Core:

.NET Core 版本.NET Core version HTTP 请求版本HTTP request version
2.12.1
2.22.2
2.0
任何其他 .NET Core 版本Any other .NET Core version 1.1

适用于