Top Tip: The easiest way to install 51Degrees is via NuGet avoiding the following manually file editing. Learn More.


There are two dlls included in this archive, one for .NET 2 (NET2/bin) and the other for .NET 4 (NET4/bin). They have identical functionality except that .NET4 does not require the configuration sections from section 3. You should only use the .NET4 dll for .NET4 and .NET4.5 web applications, otherwise use the .NET2 release.

The following entries need to be added to your existing web.config file for mobile device detection and redirection to be enabled. You do not need to include Section 2, redirect, if you do not need mobile devices to be directed to a different home page.

The comments in green do not need to be inserted but have been included for easy reference.

Where a section already exists with the primary element name, configSections or system.web/httpModules insert the section highlighted in grey before the closing tag.

Section 1

<!-- These configuration sections tell .NET how to handle the fiftyOne configuration settings further down the web.config file -->


<sectionGroup name="fiftyOne">

<section name="log" type="FiftyOne.Foundation.Mobile.Configuration.LogSection, FiftyOne.Foundation" requirePermission="false" allowDefinition="Everywhere" restartOnExternalChanges="false" allowExeDefinition="MachineToApplication"/>

<section name="redirect" type="FiftyOne.Foundation.Mobile.Configuration.RedirectSection, FiftyOne.Foundation" requirePermission="false" allowDefinition="Everywhere" restartOnExternalChanges="false" allowExeDefinition="MachineToApplication"/>

<section name="detection" type="FiftyOne.Foundation.Mobile.Detection.Configuration.DetectionSection, FiftyOne.Foundation" requirePermission="false" allowDefinition="Everywhere" restartOnExternalChanges="false" allowExeDefinition="MachineToApplication"/>



Section 2


    <!--<redirect> element controls how requests from mobile devices are handled.

    mobileHomePageUrl   Previously mobileRedirectUrl under the mobile/toolkit element.
                        A url to direct mobile devices to instead of the normal web sites 
                        landing page. (Optional)

    firstRequestOnly    If set to true only the first request received by the web site is
                        redirected to the mobileUrl when the site is accessed from a mobile
                        device. (Optional - defaults to true)

    timeout             The number of minutes of inactivity that should occur before the 
                        requesting device should be treated as making a new request to the
                        web site for the purposes of redirection. If the session is available
                        the session timeout will be used and override this value. (Optional
                        -defaults to 20 minutes)

    devicesFile         A file used to store the details of devices that have previously
                        accessed the web site to determine if they're making a subsequent
                        request. Needed to ensure multiple worker processes have a consistent
                        view of previous activity. (Optional - random behaviour will be 
                        experienced if not specified on web sites with more than one worker
                        processes). In Windows Azure this value becomes the name of devices
                        cloud table that will be used instead of a file.

    mobilePagesRegex    A regular expression that when applied to the current request Path
                        (context.Request.AppRelativeCurrentExecutionFilePath) or the requesting 
                        Urlwill return true if it should be considered a mobile page. Use 
                        this attribute to tell redirection about mobile pages derived from base
                        classes such as System.Web.UI.Page. Redirection needs to be aware of
                        mobile pages so that requests to these pages can be ignored. Any page
                        that derives from System.Web.UI.MobileControls.MobilePage will 
                        automatically be treated as a mobile page irrespective of this 
                        attribute. (Optional)

                        If set to true the redirected URL will have the original requesting Url 
                        encoded and included as the origUrl query string parameter in the 
                        redirected Url. This will enable the mobile home page to determine the 
                        original requested resource providing the option to display a mobile
                        friendly version. (Optional - defaults to false)

    locations/location  Provides details of different locations requests can be directed to based
                        on the values of defined properties associated with the device or request.
      name              A unique identifier for the location. Used for debugging in the log file.(Mandatory)                  
      url               the URL of the redirect location to use if all the properties in the 
                        collection match. (Mandatory)
      matchExpression   can be used to provide a regular expression which will take the requesting
                        URL as input match segments to be used in place of numeric parameters contained
                        within {} in the url attribute. (Optional)                       
                        The location element contains a collection of criteria that all need to match 
                        for the location to be used. Two attributes must be specified with each entry.
      property          the property of HttpRequest, HttpRequest.Browser or property to 
                        use when evaluating the matchExpression attribute. (Mandatory)
      matchExpression   a regular expression used to evaluate the value of the property. (Mandatory)                        

     <redirect firstRequestOnly="true"
        <!-- Don't redirect requests that have the noredirect query string parameter. -->
        <location name="noredirect" url="">
          <add property="Url" matchExpression="[&amp;|\?]noredirect"/>
        <!--Send tablets to their own home page.-->
        <location name="Tablet" url="~/Tablet/Default.aspx">
          <add property="is_tablet" matchExpression="true"/>

    <!--<log> element controls where and how much information should be recorded in the log.    
    logFile   The location of the log file in ASP.NET or the name of the log table in Windows Azure. (Mandatory)
    logLevel  Values include Debug|Info|Warn|Fatal and control the level of information
              logged. Detauls to Fatal if not specified. (Optional)-->

    <log logFile="~/App_Data/Log.txt" logLevel="Debug"/>

    <!--<detection> element controls where the data files used are provided. If it is not present
    the embedded device data will be used. This is the default behaviour.
    If a Premium Data license key is present in a file with the extension .lic in the bin folder,
    or provided in the FiftyOne.Foundation.Mobile.Detection.Constants.PremiumLicenceKey constant the
    binaryFilePath attribute of the detection element must be provided and the worker process must have
    modify access to the file to enable automatic updates to be downloaded.

    binaryFilePath  Path to the binary data file. (Optional - Lite / Mandatory - Premium)

    xmlFiles/add    Provides one or more data files in XML form to use for detection.
      name          The unique internal name of the XML file. (Mandatory)
      filePath      Path to the xml format file. (Mandatory)
      enabled       True or false to enable or disable processing the file. Default true. (Optional)


    <!-- IMPORTANT - Uncomment this line after you've purchased Premium Data. -->
    <!--<detection binaryFilePath="~/App_Data/"/>-->


Section 3

For IIS 6

<!-- IIS 6.0 & Visual Studio - Registers a module that is used to   detect any new requests to the web site.
Without this module mobile detection and redirection won't work.
<add name="Detector" type="FiftyOne.Foundation.Mobile.Detection.DetectorModule, FiftyOne.Foundation"/>

For IIS 7.X


<!-- IIS 7.X - Registers a module that is used to detect any new requests to the web site.
Without this module mobile detection and redirection won't work.-->

<remove name="Detector"/>
<add name="Detector"  type="FiftyOne.Foundation.Mobile.Detection.DetectorModule, FiftyOne.Foundation"/>


Section 4 - Device Database

Version 1 of Foundation required that the device data be uploaded in a separate xml file. Version 2 introduces new 51Degrees device data that is embedded into the Foundation dll so new additional files are needed in App_Data. For more information or how to setup automatic weekly updates with more device properties go to

Last edited Apr 11 at 9:12 AM by jwrosewell, version 27


No comments yet.