ASP.NET Mobile Device Detection with Additional Methods

Introduction

In ASP.NET, you can easily detect the mobile device request using Request.Browser.IsMobileDevice property and Request.UserAgent.But these functionalities don't work all the time, so to get the more appropriate results for the mobile detection and want to get more details about the mobile, the WURFL.dll is more useful.

Background

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 want to classify the desktop page and mobile page, it won't helps you out.

Using the Code

Add the WURFL.dll reference to your project.

Copy the App_Data files to your project App_Data folder.

Copy & Paste the WurflLoader.cs file to your App_Code folder.

Build the project and now you can try the sample page WebForm1.aspx in browser.

If you're looking for some open source code which fulfills a similar purpose, check out 51Degrees.mobi. I'm doing some work for them on their open source C solution, but they also have solutions implemented for Java, ASP.NET and PHP.

The libraries are referenced by the library in this project so you have to have them (note 1.2.10.0 of log4net is out of date and is a framework 2 build).

Neither of these libraries are required for mobile phone devices, they are merely personal preferneces of the author. Can I suggest a 'clean' version this project with native compressed file handling and no logging?

"To enable WURFL on your application you need to download the WURFL binaries and data. Binaries include wurfl.dll and a couple of dependencies such as log4net.dll and ICSharpCode.SharpZipLib.dll. The wurfl.dll file must be added as a reference to your project." from http://wurfl.sourceforge.net/dotNet/[^]

I'll be looking at the Wurfl API to see if I can produce a nice clean solution.

Manu, I may have alluded to the extra binaries being your fault, which it isn't, so apologies.