Я бы сначала попробовал WURFL
http://wurfl.sourceforge.net/
У них есть .NET API и очень хорошие примеры кода. http://wurfl.sourceforge.net/dotnet_index.php
Класс, который вам поможет, называется WURFLManager и имеет следующие методы:

Использовать WURFL http://wurfl.sourceforge.net/dotnet_index.php
Если вы используете asp.net mvc, вы можете использовать ActionFilter
public class MobileActionFilterAttribute : ActionFilterAttribute
{
// The WURFL database contains information about a huge number of devices and mobile browsers.
// http://wurfl.sourceforge.net/
// http://wurfl.sourceforge.net/dotnet_index.php
// http://wurfl.sourceforge.net/help_doc.php
private static readonly IWURFLManager WurflManager;
static MobileActionFilterAttribute ()
{
IWURFLConfigurer configurer = new ApplicationConfigurer();
WurflManager = WURFLManagerBuilder.Build(configurer);
}
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
HttpRequestBase request = filterContext.RequestContext.HttpContext.Request;
// We don't have ARR server for dev environment, so we still need to check to see if the current domain name is the mobile site.
if (request.Url.AbsoluteUri.StartsWith(SiteConfiguration.Current.MobileSiteAddress, StringComparison.OrdinalIgnoreCase))
{
return;
}
// Creates a WURFLRequest object from an ASP.NET HttpRequest object
WURFLRequest wurflRequest = WURFLRequestFactory.CreateRequest(HttpContext.Current.Request);
// Indicates whether the current user agent string refers to a desktop agent.
if (wurflRequest.IsDesktopRequest)
return;
// Get the information about the device
IDevice deviceInfo = WurflManager.GetDeviceForRequest(wurflRequest);
// Tells you if a device is a tablet computer (iPad and similar, regardless of OS)
bool isTablet = string.Equals(deviceInfo.GetCapability("is_tablet") ?? string.Empty, "true", StringComparison.OrdinalIgnoreCase);
if (isTablet)
{
// so we don't show the mobile site for iPad.
return;
}
// Indicates whether the current user agent string refers to a mobile device.
bool isMobileRequest = wurflRequest.IsMobileRequest;
// Tells you if a device is wireless or not. Specifically a mobile phone or a PDA are considered wireless devices, a desktop PC or a laptop are not
bool isWirelessDevice = string.Equals(deviceInfo.GetCapability("is_wireless_device") ?? string.Empty, "true", StringComparison.InvariantCultureIgnoreCase);
if (isMobileRequest && isWirelessDevice)
{
// we can redirect to the mobile site!
filterContext.Result = new RedirectResult(SiteConfiguration.Current.MobileSiteAddress);
}
}
}
Существует также 51 градусов. Моби
Стив Сандерсон рассказал о том, как это сделать, в своем блоге.
http://blog.stevensanderson.com/2010/12/17/using-51degreesmobi-foundation-for-accurate-mobile-browser-detection-on-aspnet-mvc-3/
51Degrees.Mobi Foundation - это проект с открытым исходным кодом .NET, который расширяет возможности Request.Browser, так что он получает информацию из Универсального беспроводного файла ресурсов (WURFL) - одного из наиболее полных и современных. базы данных о мобильных устройствах. Хорошая новость заключается в том, что 51Degrees.Mobi Foundation теперь доступен в виде пакета NuGet, поэтому его невероятно легко устанавливать и обновлять.