Click here to Skip to main content
15,893,564 members
Articles / Web Development / HTML

Developing Mobile specific Views using jQuery Mobile in ASP.NET MVC 4 - Part 1

Rate me:
Please Sign up or sign in to vote.
4.98/5 (22 votes)
10 Dec 2014CPOL9 min read 55.1K   2.1K   33  
Developing Mobile Specific Views using jQuery Mobile in ASP.NET MVC 4 - Part 1
<?xml version="1.0"?>
<configuration>
  <!-- Necessary to get the sections below read properly.-->
  <configSections>
    <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"/>
    </sectionGroup>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="Detector.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <fiftyOne>
    
    <!--<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)
    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)
    originalUrlAsQueryString
                        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.
                        (Optional)
      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 51Degrees.mobi property to 
                        use when evaluating the matchExpression attribute. (Mandatory)
      matchExpression   a regular expression used to evaluate the value of the property. (Mandatory)                        
                        -->
    <redirect firstRequestOnly="false"
              mobileHomePageUrl="~/mobile/default.aspx"
              timeout="20"
              devicesFile="~/App_Data/Devices.dat"
              mobilePagesRegex="mobile">
    </redirect>
    
    <!--<log> element controls where and how much information should be recorded in the log.    
    logFile   The location of the log file. (Mandatory)
    logLevel  Values include Debug|Info|Warn|Fatal and control the level of information
              logged. Defauls to Fatal if not specified. (Optional)-->
    <log logFile="~/App_Data/Log.txt" logLevel="Info"/>

    <!--<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)
    shareUsage      Set to true to share usage information with 51Degrees.mobi. Read the Usage Data FAQ 
                    to learn more. Defaults to True if not specified. (Optional)
    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/51Degrees.mobi-Premium.dat"/>-->

  </fiftyOne>
</configuration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
I am a Software Developer working on Microsoft technologies. My interest is exploring and sharing the awesomeness of emerging technologies.

Comments and Discussions