Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

HttpRequest.UserAgent Property

Gets the raw user agent string of the client browser.

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

Property Value

The raw user agent string of the client browser.

Example

The following example assigns the type identification of the requesting browser to a string variable.

[Visual Basic] 
Dim userAgent As String
 userAgent= Request.UserAgent
 If userAgent.IndexOf("MSIE 6.0") > -1 Then
    ' The browser is Microsoft Internet Explorer 6.0.
 End If
   

[C#] 
String userAgent;
userAgent = Request.UserAgent;
if (userAgent.IndexOf("MSIE 6.0") > -1) 
{
   // The browser is Microsoft Internet Explorer Version 6.0.
}
   

[C++] 
String* userAgent;
userAgent = Request->UserAgent;
if (userAgent->IndexOf(S"MSIE 6.0") > -1) 
{
   // The browser is Microsoft Internet Explorer Version 6.0.
}
   

[JScript] 
var userAgent : String = Request.UserAgent
if(userAgent.IndexOf("MSIE 6.0") > -1)
{
  // The browser is Microsoft Internet Explorer 6.0.
}
  

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpRequest Class | HttpRequest Members | System.Web Namespace

Show:
© 2015 Microsoft