public static string GetUa(HttpRequest hr)
{
try
{
string visitorBrowser = hr.UserAgent.ToString();
string originalBrowser = hr.ServerVariables["X-OperaMini-Phone-UA"];
string anotherOriginalBrowser = hr.ServerVariables["X-Device-User-Agent"]; //novarra
if (!String.IsNullOrEmpty(originalBrowser))
{
return "OPERAMINI " + originalBrowser;
}
else
{
if (!String.IsNullOrEmpty(anotherOriginalBrowser))
{
return "NOVARRA " + anotherOriginalBrowser;
}
else
{
return visitorBrowser;
}
}
}
catch
{
return "No UA Found";
}
}
public static string GetUa(HttpRequest hr) { try { string visitorBrowser = hr.UserAgent.ToString(); string originalBrowser
Share
I’d be more concerned with readability. This seems nicer to me:
Of course, if you didn’t need to prefix those strings onto the UAs and didn’t need to concern yourself with empty string user agents, then it would simply be: