Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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

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).

Remarks

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

Example

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

[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] 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.

Requirements

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

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.