HttpWebClientProtocol.UserAgent Property

Gets or sets the value for the user agent header that is sent with each request.

[Visual Basic]
Public Property UserAgent As String
public string UserAgent {get; set;}
public: __property String* get_UserAgent();
public: __property void set_UserAgent(String*);
public function get UserAgent() : String;
public function set UserAgent(String);

Property Value

The value of the HTTP protocol User-agent header. The default is "MS Web Services Client Protocol number ", where number is the version of the common language runtime (for example, 1.0.3705.0).


The user agent string allows a Web server to identify the client.


[Visual Basic] 
' 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)

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

// 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] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

HttpWebClientProtocol Class | HttpWebClientProtocol Members | System.Web.Services.Protocols Namespace | UserAgent