HttpRequest.UserAgent 属性

定义

获取所提供的客户端浏览器的原始用户代理字符串。 请注意此字符串可能为 Null。

public:
 property System::String ^ UserAgent { System::String ^ get(); };
public string UserAgent { get; }
member this.UserAgent : string
Public ReadOnly Property UserAgent As String

属性值

String

客户端浏览器的原始用户代理信息。

示例

下面的代码示例将请求浏览器的类型标识分配给字符串变量。

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
   

适用于

另请参阅