locked
Browser Detection and Page Content RRS feed

  • Question

  • User908137417 posted

    Hello

    Does anybody have an good link for help with browser detection scripts.. I have a sample script that uses ''Request.Browser.Type'', but I dont know how to serve the right content based on the browser type.  Basically I want the webpage to render correctly on a mobile phone, but still want the users to see a funtional website on pc based browser.

    Basic principal of what i'm trying to achieve.

    <script language="VB" runat="server">
      Sub Page_Load(sender as Object, e as EventArgs)
            ltlBrowserName.Text = Request.Browser.Type
            
            If Request.Browser.Type = "PC Based Browser" Then
               <html>
                    Serves Normal webpage to browser.
                </html>
            End If
           
            If Request.Browser.Type = "Mobile Phone" Then
                <html>
                 Mobile Page Content
                </html>
            End If
           
        End Sub
    </script>

    How should this be done, should I use a response re-direct to re-direct the user based on browser type.

     

    Kind Regards

    James 

    Saturday, January 20, 2007 11:14 AM

All replies

  • User512894520 posted

    Hi James,

    Try using ((System.Web.Mobile.MobileCapabilities)Request.Browser).IsMobileDevice. May not work all the time though. Have a look at this thread: http://forums.asp.net/thread/1489593.aspx

    Try searching the forum on the key 'IsMobileDevice' for other issues that people might have exprienced using it.

    Hope that helps.

    Thursday, February 1, 2007 2:23 AM
  • User907266268 posted

    James,

    See the following documentation topic - Redirecting to an ASP.NET Mobile Web Page.

    One thing to note is that you will want to keep your mobile web pages separate from your desktop ASP.NET pages.  The mobile web forms use a completely different set of controls that derive but have some stark differences (or rather limitations) from their ASP.NET desktop browser counterparts.

    Cheers,
    Colin

    Monday, February 12, 2007 12:19 AM