Click here to Skip to main content
15,849,129 members
Articles / Web Development / ASP.NET

ASP.NET Mobile Device Detection

Rate me:
Please Sign up or sign in to vote.
4.85/5 (24 votes)
21 Feb 2013CPOL2 min read 176.4K   67   12
Detect latest mobile devices/browsers using ASP.NET and 51degrees


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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Web Developer
India India
Symphony Services, Banglore, 560 087, India

Comments and Discussions

GeneralMy vote of 5 Pin
2374122-Feb-13 16:17
2374122-Feb-13 16:17 
GeneralMy vote of 5 Pin
ffernandez2322-Feb-13 2:07
ffernandez2322-Feb-13 2:07 
Question51 Degrees Value Add Pin
RTS@WORK5-Dec-12 5:30
RTS@WORK5-Dec-12 5:30 
QuestionMissing Files in App_Data Pin
Praveen Rajendran21-Nov-12 5:09
Praveen Rajendran21-Nov-12 5:09 
AnswerRe: Missing Files in App_Data Pin
varbace21-Sep-14 10:58
varbace21-Sep-14 10:58 
QuestionWURFL Use Pin
azazulhaq9-Sep-12 22:01
azazulhaq9-Sep-12 22:01 
GeneralMy vote of 5 Pin
Sk. Tajbir11-Jun-12 22:03
Sk. Tajbir11-Jun-12 22:03 
QuestionNuget package install creates dependency on Microsoft.Web.Infrastructure Pin
Jaime Premy8-Nov-11 9:29
professionalJaime Premy8-Nov-11 9:29 
GeneralRe: Nuget package install creates dependency on Microsoft.Web.Infrastructure Pin
Member 918720728-Jun-12 22:48
Member 918720728-Jun-12 22:48 
Question51Degrees Pin
Tomholmes5-Aug-11 5:51
Tomholmes5-Aug-11 5:51 
QuestionA good article Pin
rippo21-Jun-11 21:07
rippo21-Jun-11 21:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.