Tuesday, June 8, 2021

Check Is Android Device from Asp.net

 		private bool IsAndroidMobile()
        {
            //https://www.thecodingguys.net/blog/asp-net-mobile-detection
            try
            {
                string strUserAgent = Request.UserAgent.ToString().ToLower();
                bool MobileDevice = Request.Browser.IsMobileDevice;
                if (strUserAgent != null)
                {
                    if (MobileDevice == true && strUserAgent.Contains("android"))
                    {
                        return true;
                    }
                }
            }
            catch
            {
                //throw;
            }
            return false;
        }

No comments:

Post a Comment