locked
How to redirect web page - mobile RRS feed

  • Question

  • User643189141 posted

    Hi,

    how to redirect web page, for example www.domain.com / mobile, if I access the site via mobile phone.

    Thanks.

    Saturday, November 6, 2010 7:57 PM

Answers

All replies

  • User-1659704165 posted

    Hi,

    Use Response.redirect

    OR

    u want find that is Hit is done by Mobile then u have Read the header of the Browser.


    Sunday, November 7, 2010 3:01 AM
  • User1943143334 posted

    Hi,

    First u need to detect, whether the request is from Mobile device or not. For this u require .browser files.

    Download the latest browser configuration files from the following link.

    http://stephenwalther.com/blog/archive/2010/03/05/use-asp.net-4-browser-definitions-with-asp.net-3.5.aspx

    Once you download it, you can check whether the request is from Mobile device or not by using the following code.

    if (Request.Browser.IsMobileDevice)
                Response.Redirect("www.domain.com/mobile");


    Hope it helps u...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 7, 2010 4:41 AM
  • User1135281112 posted

    Hey

    Please take a look at http://51degrees.codeplex.com.  You have to change your web.config to add some elements for redirection. Below is the sample for your understanding how easily you can redirect user to different pages based on the mobile device type without modify existing ASP.NET web application pages.

    <fiftyOne>
        <redirect firstRequestOnly="true"
                  mobileHomePageUrl="~/Mobile/Default.aspx"
                  timeout="20" 
                  devicesFile="~/App_Data/Devices.dat" 
                  mobilePagesRegex="/(Apple|RIM|Nokia|Mobile)/">
    
          <locations>
    
            <location url="~/Apple/Default.aspx">
    
    <add property="MobileDeviceManufacturer" matchExpression="Apple"/>
    
            </location>
    
            <location url="~/RIM/Default.aspx">
    
    <add property="MobileDeviceManufacturer" matchExpression="RIM"/>
    
            </location>
    
            <location url="~/Nokia/Default.aspx">
    
    <add property="MobileDeviceManufacturer" matchExpression="Nokia"/>
    
            </location>
    
          </locations>
    
       </redirect>
    
        <log logFile="~/App_Data/Log.txt" 
             logLevel="Info"/>
        
        <wurfl wurflFilePath="~/App_Data/wurfl.xml.gz"
               newDeviceDetail="maximum"
               newDevicesURL="http://devices.51degrees.mobi/new.ashx"
               useActualDeviceRoot="false">
               <wurflPatches>
    <add name="browser_definitions"
        filePath="~/App_Data/web_browsers_patch.xml" enabled="true"/>
               </wurflPatches>
               <capabilitiesWhiteList>
    <add capabilityName="pointing_method"/>
               </capabilitiesWhiteList>
        </wurfl>
    </fiftyOne>
    

    It is very fast, accurate and easily to implement.

    Thanks
    Amit Patel

    Tuesday, November 9, 2010 2:34 AM