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.
public static Boolean isMobile()
{
var device = WurflLoader.GetManager().GetDeviceForRequest(HttpContext.Current.Request);
if (Convert.ToBoolean(device.GetCapability("is_wireless_device")) && !Convert.ToBoolean(device.GetCapability("is_tablet")))
{
return true;
}
else
{
return false;
}
}
Points of Interest
If there is a need of mobile browser detection and classification of mobiles needed, then this will be very useful. This is an open
standard DLL.