Code Tips,  Mobile Development

Improving device detection using the 51Degrees.Mobi package

This is a reposting of information found in Steve Sanderson post a link to the complete article is below.

using-51degreesmobi-foundation-for-accurate-mobile-browser-detection-on-aspnet-mvc-3/

51Degrees.Mobi Foundation is an open source .NET project that enhances Request.Browser so it gets its information from Wireless Universal Resource File (WURFL) – one of the most comprehensive and up-to-date databases of mobile device information.
The great news is that 51Degrees.Mobi Foundation is now available as a NuGet package, so it’s incredibly easy to install and update. If you haven’t already installed the NuGet package manager, do so right away!

Next, install 51Degrees by entering the following into the NuGet Package Manager Console:

Install-Package 51Degrees.mobi

Easy! This does the following to your project:

  • Adds a reference to FiftyOne.Foundation.dll, the assembly containing the 51Degrees logic
  • Adds AppStart_51Degrees.cs to the root of your project. This enables the 51Degrees mobile detection provider, which populates Request.Browser information whenever you ask for it
  • Adds a recent copy of the WURFL device list to your project at ~/App_Data/wurfl.xml.gz
  • Adds a folder, ~/Mobile/ containing a Web Form that displays information about the device. We don’t want this in an ASP.NET MVC application – just delete the ~/Mobile folder that it added.
  • Adds a section to your Web.config file that configures 51Degrees.Mobi Foundation with some default settings. One of its default settings is to redirect mobile browsers to the URL ~/Mobile. This would be useful if you were setting up an MVC Area called “Mobile” for mobile browsers, but since we’re just changing the master page, we don’t want this redirection to happen. Disable it by modifying Web.config: Find the element inside , and comment it out or delete it.

After following the above information the IPad is now found as a mobile device straight away under the view engine settings in the previus post.

Comments Off on Improving device detection using the 51Degrees.Mobi package