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
   

適用於

另請參閱