次の方法で共有


HttpWebClientProtocol.UserAgent プロパティ

それぞれの要求と共に送信されるユーザー エージェント ヘッダーの値を取得または設定します。

Public Property UserAgent As String
[C#]
public string UserAgent {get; set;}
[C++]
public: __property String* get_UserAgent();public: __property void set_UserAgent(String*);
[JScript]
public function get UserAgent() : String;public function set UserAgent(String);

プロパティ値

HTTP プロトコル ユーザー エージェント ヘッダーの値。既定値は "MS Web Services Client Protocol number " です。 number は、共通言語ランタイムのバージョンです (例: 1.0.3705.0)。

解説

Web サーバーでは、ユーザー エージェント文字列によりクライアントを識別します。

使用例

 
' MyMath is a proxy class.
Dim objMyMath As MyMath = 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)

[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);

[C++] 
// MyMath is a proxy class.
test::MyMath* objMyMath = new test::MyMath();

// Get the default user agent.
Console::WriteLine(S"Default user agent is: {0}", objMyMath->UserAgent);
objMyMath->UserAgent = S"My Agent";
Console::WriteLine(S"Modified user agent is: {0}", objMyMath->UserAgent);

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

HttpWebClientProtocol クラス | HttpWebClientProtocol メンバ | System.Web.Services.Protocols 名前空間 | UserAgent