Search code examples
mobileasp-classicuser-agent

Detect mobile user agent from classic ASP and redirect on session start


I'd like to detect a mobile user agent and redirect them when the session starts in a classic ASP app. Does anyone know a good way to pull this off?


Solution

  • Take a look at:

    http://mobiforge.com/developing/story/lightweight-device-detection-asp

    sub is_mobile()
      Dim Regex, match
      Set Regex = New RegExp
         With Regex
            .Pattern = "(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|windows ce|pda|mobile|mini|palm|ipad)"
            .IgnoreCase = True
            .Global = True
          End With
       match = Regex.test(Request.ServerVariables("HTTP_USER_AGENT"))
       If match Then
          return True
       Else
          return False
       End If
    End Sub
    

    *Disclaimer: the code may not work, as I have no method to test it and little knowledge of classic ASP.