使用英语阅读

通过


HttpWebClientProtocol.UserAgent 属性

定义

获取或设置随每个请求发送的用户代理标头的值。

public string UserAgent { get; set; }
[System.ComponentModel.Browsable(false)]
public string UserAgent { get; set; }

属性值

HTTP 协议用户代理标头的值。 默认为“MS Web Services Client Protocol number”,其中 number 为公共语言运行时的版本(例如 1.0.3705.0)。

属性

示例

// MyMath is a proxy class.
MyMath objMyMath = new MyMath();

// Get the default user agent.
Console.WriteLine("Default user agent is: " + objMyMath.UserAgent);
objMyMath.UserAgent = "My Agent";
Console.WriteLine("Modified user agent is: " + objMyMath.UserAgent);

注解

用户代理字符串允许 Web 服务器标识客户端。

适用于

产品 版本
.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

另请参阅