UserAgent Property

HttpRequest.UserAgent Property

 

Gets the raw user agent string of the client browser.

Namespace:   System.Web
Assembly:  System.Web (in System.Web.dll)

public string UserAgent { get; }

Property Value

Type: System.String

The raw user agent string of the client browser.

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

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

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft