HttpWebClientProtocol.UserAgent Property

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

Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in

property String^ UserAgent {
	String^ get ();
	void set (String^ value);
/** @property */
public String get_UserAgent ()

/** @property */
public void set_UserAgent (String value)

public function get UserAgent () : String

public function set UserAgent (value : String)

Not applicable.

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.

// MyMath is a proxy class.
test::MyMath^ objMyMath = gcnew test::MyMath;

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

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

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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0