HttpRequest.UserAgent HttpRequest.UserAgent HttpRequest.UserAgent HttpRequest.UserAgent Property

定义

获取所提供的客户端浏览器的原始用户代理字符串。Gets the raw user agent string of the client browser that has been provided. 请注意此字符串可能为 Null。Please note it may be null.

public:
 property System::String ^ UserAgent { System::String ^ get(); };
public string UserAgent { get; }
member this.UserAgent : string
Public ReadOnly Property UserAgent As 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.
}
   
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
   

适用于

另请参阅