HttpRequest.UserAgent Property

Definition

Gets the raw user agent string of the client browser that has been provided. Please note it may be null.

C#
public string UserAgent { get; }

Property Value

The raw user agent string of the client browser.

Examples

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

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

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also