Detecting the browser once IE7 comes out

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

I want to make sure I am doing a browser detection that will work once IE7
is released. My current detection statement (written using VB.NET) is:


If Me.Request.Browser.Browser.ToUpper() = "IE" Then
'Code to use for Internet Explorer browsers
Else
'Code to use for browsers other than Internet Explorer
End If


In what ways would I need to modify this to make it work for IE7 as well?
Thanks.
 
Nathan said:
I want to make sure I am doing a browser detection that will work once IE7
is released. My current detection statement (written using VB.NET) is:


If Me.Request.Browser.Browser.ToUpper() = "IE" Then
'Code to use for Internet Explorer browsers
Else
'Code to use for browsers other than Internet Explorer
End If


In what ways would I need to modify this to make it work for IE7 as well?
Thanks.

The Beta is freely available, and may help you discover other areas
where you need to update/amend your site for IE7. Microsoft have also
got various resources for web developers to prepare for IE7, which I
think you can find on the microsoft web site.

Damien
 
Firstly, please don't cross-post...
If Me.Request.Browser.Browser.ToUpper() = "IE" Then
'Code to use for Internet Explorer browsers
Else
'Code to use for browsers other than Internet Explorer
End If


In what ways would I need to modify this to make it work for IE7 as well?

A five-second inspection of the Request.Browser class would have revealed
all its other properties...

My Beta3 copy of IE7 (7.0.5450.4) returns the following values (in
parentheses) to the Request.Browser object:

..ActiveXControls (True)
..AOL (False)
..BackgroundSounds (True)
..Beta (False)
..Browser (IE)
..CDF (False)
..ClrVersion (2.0.50727)
..Cookies (True)
..Crawler (False)
..EcmaScriptVersion (1.2)
..Frames (True)
..JavaApplets (True)
..JavaScript (True)
..MajorVersion (7)
..MinorVersion (0)
..MSDomVersion (7.0)
..Platform (WinXP)
..Tables (True)
..Type (IE7)
..VBScript (True)
..Version (7.0)
..W3CDomVersion (1.0)
..Win16 (False)
..Win32 (True)

I'm slightly puzzled about the .Beta property, which I would have expected
to return True instead of False...
 
Thank you for that sample. I think the reason for it returning Beta=False is
because of where it gets the properties, which is from a section of the
Web.config file called browserCaps which is matched against the User-Agent
string using regular expressions (or something like that, but I know it
doesn't send all the properties individually). I personally think that
Microsoft should do one of the following as far as getting the
Request.Browser object:

1. Create a different class that accesses a web service that they create to
determine the property values

OR

2. Give periodic updates for the <browserCaps> section of the Web.config
file (they give periodic updates for Windows, Office, and several other
pieces of software, why not for this?)

But rather than complain about it, I'm happy for now since if your sample is
correct and the .Browser property returns "IE" I don't need to make any
changes to my code anyway. Thanks.
 
You could choose to just support up level browsers by setting the
ClientTarget.

http://msdn2.microsoft.com/en-us/library/system.web.ui.page.clienttarget.aspx

You can set it also in the @Page directives.

http://msdn2.microsoft.com/en-us/library/x3k2ssx2.aspx

You would set it to "uplevel" to assume up level support. Since more
than 98% of your traffic will likely be coming from browsers which are
now "up level", you may find that is reasonable most of the time. It
is unlikely you will see IE4 or Netscape 4 browsers hitting your
website at all.

In fact, "up level" describes nearly all browsers released in the last
5 years which all have Cookie, CSS and Javascript support. A new
definition for Web 2.0 may need to be introduced with a wider set of
properties detailing features expected of this next level.

Brennan Stehling
http://brennan.offwhite.net/blog/
 
My original question had nothing to do with whether or not I support up
level browsers (I am not usually specific to what browser is being used for
anything other than whether it uses JScript of JavaScript). My original
question was how to detect whether I am using IE with a method that will
work even once IE7 is available. The basic question my code is [hopefully]
asking is "Am I using Internet Explorer or some other browser?" I normally
do assume my visitors are using an up level browser, because anybody using a
browser that old really doesn't care whether or not the page works.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Brennan Stehling said:
You could choose to just support up level browsers by setting the
ClientTarget.

http://msdn2.microsoft.com/en-us/library/system.web.ui.page.clienttarget.aspx

You can set it also in the @Page directives.

http://msdn2.microsoft.com/en-us/library/x3k2ssx2.aspx

You would set it to "uplevel" to assume up level support. Since more
than 98% of your traffic will likely be coming from browsers which are
now "up level", you may find that is reasonable most of the time. It
is unlikely you will see IE4 or Netscape 4 browsers hitting your
website at all.

In fact, "up level" describes nearly all browsers released in the last
5 years which all have Cookie, CSS and Javascript support. A new
definition for Web 2.0 may need to be introduced with a wider set of
properties detailing features expected of this next level.

Brennan Stehling
http://brennan.offwhite.net/blog/
 
I'm using pretty much that exact code and have a Vista Beta 2 machine for testing and the server detects the IE7 running on the
Vista machine just fine (although I don't have the Upper specification and it still works).

By the way, IE7 beta is already out for use with XP (but it won't work with W2K from what I gather), so you don't even need a vista
machine to test it.

Jeff

Nathan Sokalski said:
My original question had nothing to do with whether or not I support up
level browsers (I am not usually specific to what browser is being used for
anything other than whether it uses JScript of JavaScript). My original
question was how to detect whether I am using IE with a method that will
work even once IE7 is available. The basic question my code is [hopefully]
asking is "Am I using Internet Explorer or some other browser?" I normally
do assume my visitors are using an up level browser, because anybody using a
browser that old really doesn't care whether or not the page works.
 
That is good to know, but I seem to remember the beta versions (or at least
some of them) using a different UserAgent string than what the final version
will. Whether this will affect the detection code, I can't remember.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Jeff said:
I'm using pretty much that exact code and have a Vista Beta 2 machine for
testing and the server detects the IE7 running on the
Vista machine just fine (although I don't have the Upper specification and
it still works).

By the way, IE7 beta is already out for use with XP (but it won't work
with W2K from what I gather), so you don't even need a vista
machine to test it.

Jeff

Nathan Sokalski said:
My original question had nothing to do with whether or not I support up
level browsers (I am not usually specific to what browser is being used
for
anything other than whether it uses JScript of JavaScript). My original
question was how to detect whether I am using IE with a method that will
work even once IE7 is available. The basic question my code is
[hopefully]
asking is "Am I using Internet Explorer or some other browser?" I
normally
do assume my visitors are using an up level browser, because anybody
using a
browser that old really doesn't care whether or not the page works.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Brennan Stehling said:
You could choose to just support up level browsers by setting the
ClientTarget.

http://msdn2.microsoft.com/en-us/library/system.web.ui.page.clienttarget.aspx

You can set it also in the @Page directives.

http://msdn2.microsoft.com/en-us/library/x3k2ssx2.aspx

You would set it to "uplevel" to assume up level support. Since more
than 98% of your traffic will likely be coming from browsers which are
now "up level", you may find that is reasonable most of the time. It
is unlikely you will see IE4 or Netscape 4 browsers hitting your
website at all.

In fact, "up level" describes nearly all browsers released in the last
5 years which all have Cookie, CSS and Javascript support. A new
definition for Web 2.0 may need to be introduced with a wider set of
properties detailing features expected of this next level.

Brennan Stehling
http://brennan.offwhite.net/blog/

Nathan Sokalski wrote:
I want to make sure I am doing a browser detection that will work once
IE7
is released. My current detection statement (written using VB.NET) is:


If Me.Request.Browser.Browser.ToUpper() = "IE" Then
'Code to use for Internet Explorer browsers
Else
'Code to use for browsers other than Internet Explorer
End If


In what ways would I need to modify this to make it work for IE7 as
well?
Thanks.
 
re:
Whether this will affect the detection code, I can't remember.

Nathan,

Request.Browser.Type returns "IE7".
Request.Browser.Browser + Request.Browser.Version returns "IE7.0".

You can use either of those to detect IE 7.0.



Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
Nathan Sokalski said:
That is good to know, but I seem to remember the beta versions (or at least some of them) using a
different UserAgent string than what the final version will. Whether this will affect the
detection code, I can't remember.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

Jeff said:
I'm using pretty much that exact code and have a Vista Beta 2 machine for testing and the server
detects the IE7 running on the
Vista machine just fine (although I don't have the Upper specification and it still works).

By the way, IE7 beta is already out for use with XP (but it won't work with W2K from what I
gather), so you don't even need a vista
machine to test it.

Jeff

Nathan Sokalski said:
My original question had nothing to do with whether or not I support up
level browsers (I am not usually specific to what browser is being used for
anything other than whether it uses JScript of JavaScript). My original
question was how to detect whether I am using IE with a method that will
work even once IE7 is available. The basic question my code is [hopefully]
asking is "Am I using Internet Explorer or some other browser?" I normally
do assume my visitors are using an up level browser, because anybody using a
browser that old really doesn't care whether or not the page works.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/

You could choose to just support up level browsers by setting the
ClientTarget.

http://msdn2.microsoft.com/en-us/library/system.web.ui.page.clienttarget.aspx

You can set it also in the @Page directives.

http://msdn2.microsoft.com/en-us/library/x3k2ssx2.aspx

You would set it to "uplevel" to assume up level support. Since more
than 98% of your traffic will likely be coming from browsers which are
now "up level", you may find that is reasonable most of the time. It
is unlikely you will see IE4 or Netscape 4 browsers hitting your
website at all.

In fact, "up level" describes nearly all browsers released in the last
5 years which all have Cookie, CSS and Javascript support. A new
definition for Web 2.0 may need to be introduced with a wider set of
properties detailing features expected of this next level.

Brennan Stehling
http://brennan.offwhite.net/blog/

Nathan Sokalski wrote:
I want to make sure I am doing a browser detection that will work once
IE7
is released. My current detection statement (written using VB.NET) is:


If Me.Request.Browser.Browser.ToUpper() = "IE" Then
'Code to use for Internet Explorer browsers
Else
'Code to use for browsers other than Internet Explorer
End If


In what ways would I need to modify this to make it work for IE7 as well?
Thanks.
 
Back
Top