HttpWebClientProtocol.UserAgent 屬性

定義

針對隨著每個要求所傳送的使用者代理標頭,取得或設定值。

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

屬性值

HTTP 通訊協定使用者代理標頭的值。 預設值為 MS Web 服務用戶端通訊協定 number,其中的 number 是 Common Language Runtime 的版本 (例如 1.0.3705.0)。

屬性

範例

C#
// 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

另請參閱