Click here to Skip to main content

ASP.NET Mobile Device Detection


In ASP.NET, you can easily detect the mobile device request using Request.Browser.IsMobileDevice property and Request.UserAgent.

The following code checks the IsMobileDevice property and redirects to the mobile specific page:

protected void Page_Load(object sender, EventArgs e)
    if (Request.Browser.IsMobileDevice)

If you request "default.aspx" from mobile browser, it will redirect to default_mobile.aspx page

Step 1: Request from Mobile User Agent

Change the User Agent (Safari Browser).


Step 2: Request "default.aspx"

A "default.aspx" request automatically redirects to "default_mobile.aspx" because HTTP request is from mobile user agent.


Problem with Latest Browsers

Some of the popular mobile devices/browsers won’t be detected using this way because ASP.NET browser files are not supported in Opera Mobile or Android devices. That means if you request "default.aspx" from Opera mobile browser, it won't redirect to "default_mobile.aspx" Frown | :-(



You can fix this problem using 51Degrees.Mobi package. 51Degrees.Mobi package is an open source .NET project that enhances Request.Browser using from Wireless Universal Resource File (WURFL). WURFL is one of the comprehensive and up-to-date databases of mobile device information.

You can easily install/download the 51Degrees using NuGet package manager in VS 2010.

Install 51Degrees

Step 1: Open NuGet Package Manager


Step 2: Install 51Degrees


"Install-Package" command automatically adds "FiftyOne.Foundation.dll" reference and necessary files under "App_Data" folder as shown below:



Step 3: Define 51Degrees Configuration Section


Step 4: Define 51Degrees/wurfl


The above configuration changes automatically update the ASP.NET browser detection capabilities and you can easily detect the modern mobile devices/browsers. If you request "default.aspx" from Opera mobile browser after this configuration changes, it will automatically redirect to "default_mobile.aspx" page as shown below. Smile | :)



I hopes you got some idea about 51Degrees, WURFL and ASP.NET browser detection. Thanks for reading. This is the same as my original post ASP.NET mobile device detection.

Web02 | 2.8.160204.4 | Advertise | Privacy
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service