User Agent Parser
UserAgentValid Method
Example 



KellermanSoftware.UserAgentParser Namespace > UserAgentValidLogic Class : UserAgentValid Method
The user agent.
Returns string.Empty if the user agent is valid, otherwise a validation message
Syntax
'Declaration
 
Public Function UserAgentValid( _
   ByVal userAgent As String _
) As String
'Usage
 
Dim instance As UserAgentValidLogic
Dim userAgent As String
Dim value As String
 
value = instance.UserAgentValid(userAgent)
public string UserAgentValid( 
   string userAgent
)
public:
String^ UserAgentValid( 
   String^ userAgent
) 

Parameters

userAgent
The user agent.

Return Value

string.Empty or validation message
Example
UserAgentValidLogic userAgentValidLogic = new UserAgentValidLogic();
 
//Parameters
string userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25";
 
string result = userAgentValidLogic.UserAgentValid(userAgent);
 
Console.WriteLine("User Agent: " + userAgent);
 
if (string.IsNullOrEmpty(result))
    Console.WriteLine("Was Valid");
 
Console.WriteLine();
 
userAgent = "john.doe@hotmail.com";
result = userAgentValidLogic.UserAgentValid(userAgent);
 
Console.WriteLine("User Agent: " + userAgent);
 
if (!string.IsNullOrEmpty(result))
    Console.WriteLine(result);
Dim userAgentValidLogic As New UserAgentValidLogic()
 
'Parameters
Dim userAgent As String = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"
 
Dim result As String = userAgentValidLogic.UserAgentValid(userAgent)
 
Console.WriteLine("User Agent: " & userAgent)
 
If String.IsNullOrEmpty(result) Then
    Console.WriteLine("Was Valid")
End If
 
Console.WriteLine()
 
userAgent = "john.doe@hotmail.com"
result = userAgentValidLogic.UserAgentValid(userAgent)
 
Console.WriteLine("User Agent: " & userAgent)
 
If Not String.IsNullOrEmpty(result) Then
    Console.WriteLine(result)
End If
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

UserAgentValidLogic Class
UserAgentValidLogic Members