Blackberry or IE detection

Bill Humphrey

Active member
Joined
Apr 10, 2008
Messages
35
Programming Experience
Beginner
I need to detect whether a users is trying to open a web site using a blackberry or not, is there a way to detect whether a users is using a blackberry or IE?

Kind Regards
Bill Humphrey
 
I don't know what a blackberry uses but you can detect browsers this way.

Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
If InStr(Request.ServerVariables("http_user_agent"), "Safari") Or InStr(Request.ServerVariables("http_user_agent"), "Chrome") Then
'do something
End If
End Sub
 
What I have done in the past is like what BanditSteve suggested. I have a config file that houses a list of mobile user agents. I adapted something similar to this: isMobile. php mobile detection goodness. | Richard Shepherd in an HTTPModule (VB.NEt Of course).
The HTTPModule runs before the page is loaded and if it finds that the request is from any of the items in my list I pass them to our mobile site. One thing to remeber when using custom HTTPModules or Handlers is that any child apps (Virtual Directories) will inherit them unless you clear those sections in the web.confg files.


Daniel
 
Back
Top