Wednesday, March 28, 2012

String.Compare\Browser Detect\VB

VS.NET 2002\Web\VB

This is what Request.UserAgent returns for Mozilla Firebird:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007
Firebird/0.7

Is there any reason why this shouldn't work to identify a visitor using that
browser?

If String.Compare(Request.UserAgent, "firebird", True) = True Then
[code]
End If

Using Mozilla Firebird, it jumps right over it. As a test, I replaced
"firebird" with "msie," and it catches the IE browser with no problem. So
why not firebird?

I can't use browser name or browser type because it returns Netscape, not
Firebird.

Thanks,
GeorgeI think you want String.IndexOf, not String.Compare.
http://msdn.microsoft.com/library/d...ndexoftopic.asp

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"George" <--@.--.--> wrote in message
news:1inVb.83$fV5.401@.bgtnsc04-news.ops.worldnet.att.net...
> VS.NET 2002\Web\VB
> This is what Request.UserAgent returns for Mozilla Firebird:
> Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007
> Firebird/0.7
> Is there any reason why this shouldn't work to identify a visitor using
that
> browser?
> If String.Compare(Request.UserAgent, "firebird", True) = True Then
> [code]
> End If
> Using Mozilla Firebird, it jumps right over it. As a test, I replaced
> "firebird" with "msie," and it catches the IE browser with no problem. So
> why not firebird?
> I can't use browser name or browser type because it returns Netscape, not
> Firebird.
> Thanks,
> George
Thanks, Eric, that did work. At a loss as to why the other one didn't work,
though.

George

"Eric Lawrence [MSFT]" <e_lawrence@.hotmail.com> wrote in message
news:O5DgI$i7DHA.1052@.TK2MSFTNGP12.phx.gbl...
> I think you want String.IndexOf, not String.Compare.
http://msdn.microsoft.com/library/d...ndexoftopic.asp
> --
> Thanks,
> Eric Lawrence
> Program Manager
> Assistance and Worldwide Services
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
>
> "George" <--@.--.--> wrote in message
> news:1inVb.83$fV5.401@.bgtnsc04-news.ops.worldnet.att.net...
> > VS.NET 2002\Web\VB
> > This is what Request.UserAgent returns for Mozilla Firebird:
> > Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007
> > Firebird/0.7
> > Is there any reason why this shouldn't work to identify a visitor using
> that
> > browser?
> > If String.Compare(Request.UserAgent, "firebird", True) = True Then
> > [code]
> > End If
> > Using Mozilla Firebird, it jumps right over it. As a test, I replaced
> > "firebird" with "msie," and it catches the IE browser with no problem.
So
> > why not firebird?
> > I can't use browser name or browser type because it returns Netscape,
not
> > Firebird.
> > Thanks,
> > George
String.Compare looks to see if the exact string matches (with or without the
case-sensitive flag).

The string "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5)
Gecko/20031007 Firebird/0.7" is not an exact match for the string
"firebird".

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"George" <--@.--.--> wrote in message
news:uDwVb.199534$6y6.4020354@.bgtnsc05-news.ops.worldnet.att.net...
> Thanks, Eric, that did work. At a loss as to why the other one didn't
work,
> though.
> George
>
> "Eric Lawrence [MSFT]" <e_lawrence@.hotmail.com> wrote in message
> news:O5DgI$i7DHA.1052@.TK2MSFTNGP12.phx.gbl...
> > I think you want String.IndexOf, not String.Compare.
http://msdn.microsoft.com/library/d...ndexoftopic.asp
> > --
> > Thanks,
> > Eric Lawrence
> > Program Manager
> > Assistance and Worldwide Services
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> > "George" <--@.--.--> wrote in message
> > news:1inVb.83$fV5.401@.bgtnsc04-news.ops.worldnet.att.net...
> > > VS.NET 2002\Web\VB
> > > > This is what Request.UserAgent returns for Mozilla Firebird:
> > > > Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007
> > > Firebird/0.7
> > > > Is there any reason why this shouldn't work to identify a visitor
using
> > that
> > > browser?
> > > > If String.Compare(Request.UserAgent, "firebird", True) = True Then
> > > [code]
> > > End If
> > > > Using Mozilla Firebird, it jumps right over it. As a test, I replaced
> > > "firebird" with "msie," and it catches the IE browser with no problem.
> So
> > > why not firebird?
> > > > I can't use browser name or browser type because it returns Netscape,
> not
> > > Firebird.
> > > > Thanks,
> > > George
> > >

0 comments:

Post a Comment