How can I write this shorter?
Posted
by nLL
on Stack Overflow
See other posts from Stack Overflow
or by nLL
Published on 2010-05-02T14:52:12Z
Indexed on
2010/05/02
15:27 UTC
Read the original article
Hit count: 191
c#
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";
}
}
© Stack Overflow or respective owner