c# - Detect UserAgent is not from Mobile -


condition hi have function detect if client request mobile or not. function 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: not enough detect handheld device got list of string on internet compare if 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 devices went on incresaing list long

i want reverse condition. want detect if request pc or laptop not handheld device. there way so? or thinking in wrong way?

this nice blog think you.

it recommends using request.browser.ismobiledevice


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -