Detecting Mobile Browsers
As discussed in our last meeting, web applications can be built to handle both PC browsers and mobile browsers. To do so, the application needs to detect if the browser is a mobile device and redirect the application to a page designed to display UI adequate for the smaller mobile browser. Detecting the browser is done using the following code sample, and it's typically placed in the Page_Load() of the login.aspx or default.aspx Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try If Not IsPostBack Then If Request.Browser.IsMobileDevice = True Then Response.Redirect("mobile/login.aspx") End If End If Catch ex As Exception ProcessEx(ex) End Try End Sub

Comments
Post a Comment