Condition Hi currently I have a function to detect if the client request is from mobile or not. The function is as below.
public bool IsHandheld()
{
bool status = false;
string strUserAgent = Request.UserAgent.ToString().ToLower();
if (strUserAgent != null)
{
if (Request.Browser.IsMobileDevice == true || strUserAgent.Contains("iphone") ||
strUserAgent.Contains("blackberry") || strUserAgent.Contains("mobile") ||
strUserAgent.Contains("windows ce") || strUserAgent.Contains("opera mini") ||
strUserAgent.Contains("palm"))
{
status = true;
}
}
return status;
}
Problem: This is not enough to detect the handheld device so I got a list of string over internet to compare if it is contained in Userstring
new string[] { "blackberry" ,"iphone","mobile","windows ce","opera mini",
"palm","symbianos", "ipad", "symbianos", "ipod", "blackberry",
"sonyericsson", "android", "samsung", "nokia", "wap", "motor"
});
If the devices went on incresaing then this list would be long
I want to reverse the condition. I want to detect if the request is from PC or laptop not from handheld device. Is there any way to do so? Or am I thinking in the wrong way?
This is nice Blog i think this will help you.
It recommends using
request.Browser.IsMobileDevice