Sunday, January 16, 2011

Detecting Platform on a Device in ASP.NET

This code will determine the platform in .NET and based on the it will display the respective logo. I used this for my MobileExec 2011 program.



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"))
                {
                    Response.Redirect("Default.aspx");
                }
            }

No comments:

Post a Comment

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...