Monday, February 25, 2013

Detecting Mobile Device Request in ASP.NET


When developing a ASP.NET website for both mobile and PC users, It is very important that you detect the mobile request properly and redirect user to mobile pages.

HttpBrowserCapabilities Version = Request.Browser;
 if ( Version.IsMobileDevice = true)
 {
  Response.Redirect("yourPage-For-Mobiles.aspx");
 }
 else
 {
  Response.Redirect("yourPage-For-PC-Users.aspx");
 }

Below are some recommended resolutions for mobile devices.

Device           Screen res (height x width) 
iPhone             320 x 480
iPhone 4          320 x 480 (scaled by a factor of 2)
Nokia N97      360 x 640
HTC Legend   320 x 480
LG eXpo        480 x 800

No comments:
Write comments
Recommended Posts × +