469,964 Members | 1,503 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

Does HttpBrowserCapabilities work?

I just added this line of code to a simple aspx page:

HttpBrowserCapabilities browserCap = new HttpBrowserCapabilities();

Yet when I used QuickWatch in Debug mode to inspect 'browserCap' all the
properties were null. How come?

--
Robert W.
Vancouver, BC
www.mwtech.com

Apr 28 '06 #1
5 2680
Try this :

HttpBrowserCapabilities bc = Request.Browser;
Response.Write("<p>Browser Capabilities:</p>");
Response.Write("Type = " + bc.Type + "<br>");
Response.Write("Name = " + bc.Browser + "<br>");
Response.Write("Version = " + bc.Version + "<br>");
Response.Write("Major Version = " + bc.MajorVersion + "<br>");
Response.Write("Minor Version = " + bc.MinorVersion + "<br>");
Response.Write("Platform = " + bc.Platform + "<br>");
Response.Write("Is Beta = " + bc.Beta + "<br>");
Response.Write("Is Crawler = " + bc.Crawler + "<br>");
Response.Write("Is AOL = " + bc.AOL + "<br>");
Response.Write("Is Win16 = " + bc.Win16 + "<br>");
Response.Write("Is Win32 = " + bc.Win32 + "<br>");
Response.Write("Supports Frames = " + bc.Frames + "<br>");
Response.Write("Supports Tables = " + bc.Tables + "<br>");
Response.Write("Supports Cookies = " + bc.Cookies + "<br>");
Response.Write("Supports VB Script = " + bc.VBScript + "<br>");
Response.Write("Supports JavaScript = " + bc.JavaScript + "<br>");
Response.Write("Supports Java Applets = " + bc.JavaApplets + "<br>");
Response.Write("Supports ActiveX Controls = " + bc.ActiveXControls + "<br>");
Response.Write("CDF = " + bc.CDF + "<br>");


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
I just added this line of code to a simple aspx page:

HttpBrowserCapabilities browserCap = new HttpBrowserCapabilities();

Yet when I used QuickWatch in Debug mode to inspect 'browserCap' all the
properties were null. How come?

--
Robert W.
Vancouver, BC
www.mwtech.com

Apr 28 '06 #2
Oh I see, it's a data structure, not a [populated] object in and of itself.
Thanks!
--
Robert W.
Vancouver, BC
www.mwtech.com

"Juan T. Llibre" wrote:
Try this :

HttpBrowserCapabilities bc = Request.Browser;
Response.Write("<p>Browser Capabilities:</p>");
Response.Write("Type = " + bc.Type + "<br>");
Response.Write("Name = " + bc.Browser + "<br>");
Response.Write("Version = " + bc.Version + "<br>");
Response.Write("Major Version = " + bc.MajorVersion + "<br>");
Response.Write("Minor Version = " + bc.MinorVersion + "<br>");
Response.Write("Platform = " + bc.Platform + "<br>");
Response.Write("Is Beta = " + bc.Beta + "<br>");
Response.Write("Is Crawler = " + bc.Crawler + "<br>");
Response.Write("Is AOL = " + bc.AOL + "<br>");
Response.Write("Is Win16 = " + bc.Win16 + "<br>");
Response.Write("Is Win32 = " + bc.Win32 + "<br>");
Response.Write("Supports Frames = " + bc.Frames + "<br>");
Response.Write("Supports Tables = " + bc.Tables + "<br>");
Response.Write("Supports Cookies = " + bc.Cookies + "<br>");
Response.Write("Supports VB Script = " + bc.VBScript + "<br>");
Response.Write("Supports JavaScript = " + bc.JavaScript + "<br>");
Response.Write("Supports Java Applets = " + bc.JavaApplets + "<br>");
Response.Write("Supports ActiveX Controls = " + bc.ActiveXControls + "<br>");
Response.Write("CDF = " + bc.CDF + "<br>");


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
I just added this line of code to a simple aspx page:

HttpBrowserCapabilities browserCap = new HttpBrowserCapabilities();

Yet when I used QuickWatch in Debug mode to inspect 'browserCap' all the
properties were null. How come?

--
Robert W.
Vancouver, BC
www.mwtech.com


Apr 28 '06 #3
re:
Oh I see, it's a data structure, not a [populated] object in and of itself.
Exactly...

re: Thanks!
You're more than welcome! Have a great week-end!

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com... Oh I see, it's a data structure, not a [populated] object in and of itself.
Thanks!
--
Robert W.
Vancouver, BC
www.mwtech.com

"Juan T. Llibre" wrote:
Try this :

HttpBrowserCapabilities bc = Request.Browser;
Response.Write("<p>Browser Capabilities:</p>");
Response.Write("Type = " + bc.Type + "<br>");
Response.Write("Name = " + bc.Browser + "<br>");
Response.Write("Version = " + bc.Version + "<br>");
Response.Write("Major Version = " + bc.MajorVersion + "<br>");
Response.Write("Minor Version = " + bc.MinorVersion + "<br>");
Response.Write("Platform = " + bc.Platform + "<br>");
Response.Write("Is Beta = " + bc.Beta + "<br>");
Response.Write("Is Crawler = " + bc.Crawler + "<br>");
Response.Write("Is AOL = " + bc.AOL + "<br>");
Response.Write("Is Win16 = " + bc.Win16 + "<br>");
Response.Write("Is Win32 = " + bc.Win32 + "<br>");
Response.Write("Supports Frames = " + bc.Frames + "<br>");
Response.Write("Supports Tables = " + bc.Tables + "<br>");
Response.Write("Supports Cookies = " + bc.Cookies + "<br>");
Response.Write("Supports VB Script = " + bc.VBScript + "<br>");
Response.Write("Supports JavaScript = " + bc.JavaScript + "<br>");
Response.Write("Supports Java Applets = " + bc.JavaApplets + "<br>");
Response.Write("Supports ActiveX Controls = " + bc.ActiveXControls + "<br>");
Response.Write("CDF = " + bc.CDF + "<br>");


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
>I just added this line of code to a simple aspx page:
>
> HttpBrowserCapabilities browserCap = new HttpBrowserCapabilities();
>
> Yet when I used QuickWatch in Debug mode to inspect 'browserCap' all the
> properties were null. How come?
>
> --
> Robert W.
> Vancouver, BC
> www.mwtech.com
>


Apr 28 '06 #4
just remember, browsercaps just looks at the UserAgent string sent by the
browser, and lookups the values based on the string, so the browsercaps
values are not alway accurate. for example, JavaScript is true for IE, but
the user may have javascript disabled. also some browser (say opera) lie
about who they are.

-- bruce (sqlwork.com)

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:u0**************@TK2MSFTNGP02.phx.gbl...
re:
Oh I see, it's a data structure, not a [populated] object in and of
itself.


Exactly...

re:
Thanks!


You're more than welcome! Have a great week-end!

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com...
Oh I see, it's a data structure, not a [populated] object in and of
itself.
Thanks!
--
Robert W.
Vancouver, BC
www.mwtech.com

"Juan T. Llibre" wrote:
Try this :

HttpBrowserCapabilities bc = Request.Browser;
Response.Write("<p>Browser Capabilities:</p>");
Response.Write("Type = " + bc.Type + "<br>");
Response.Write("Name = " + bc.Browser + "<br>");
Response.Write("Version = " + bc.Version + "<br>");
Response.Write("Major Version = " + bc.MajorVersion + "<br>");
Response.Write("Minor Version = " + bc.MinorVersion + "<br>");
Response.Write("Platform = " + bc.Platform + "<br>");
Response.Write("Is Beta = " + bc.Beta + "<br>");
Response.Write("Is Crawler = " + bc.Crawler + "<br>");
Response.Write("Is AOL = " + bc.AOL + "<br>");
Response.Write("Is Win16 = " + bc.Win16 + "<br>");
Response.Write("Is Win32 = " + bc.Win32 + "<br>");
Response.Write("Supports Frames = " + bc.Frames + "<br>");
Response.Write("Supports Tables = " + bc.Tables + "<br>");
Response.Write("Supports Cookies = " + bc.Cookies + "<br>");
Response.Write("Supports VB Script = " + bc.VBScript + "<br>");
Response.Write("Supports JavaScript = " + bc.JavaScript + "<br>");
Response.Write("Supports Java Applets = " + bc.JavaApplets + "<br>");
Response.Write("Supports ActiveX Controls = " + bc.ActiveXControls +
"<br>");
Response.Write("CDF = " + bc.CDF + "<br>");


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
>I just added this line of code to a simple aspx page:
>
> HttpBrowserCapabilities browserCap = new HttpBrowserCapabilities();
>
> Yet when I used QuickWatch in Debug mode to inspect 'browserCap' all
> the
> properties were null. How come?
>
> --
> Robert W.
> Vancouver, BC
> www.mwtech.com
>


Apr 28 '06 #5
re:
just remember, browsercaps just looks at the UserAgent string ...snip... so the browsercaps values
are not always accurate.
Unfortunately, the userAgent string is the *only* way to identify browsers.

If someone comes to my site while spoofing their userAgent,
they deserve whatever rendering problems they get.

;-)

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"bruce barker (sqlwork.com)" <b_*************************@sqlwork.com> wrote in message
news:Ov**************@TK2MSFTNGP05.phx.gbl... just remember, browsercaps just looks at the UserAgent string sent by the browser, and lookups the
values based on the string, so the browsercaps values are not alway accurate. for example,
JavaScript is true for IE, but the user may have javascript disabled. also some browser (say
opera) lie about who they are.

-- bruce (sqlwork.com)

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:u0**************@TK2MSFTNGP02.phx.gbl...
re:
Oh I see, it's a data structure, not a [populated] object in and of itself.


Exactly...

re:
Thanks!


You're more than welcome! Have a great week-end!

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com...
Oh I see, it's a data structure, not a [populated] object in and of itself.
Thanks!
--
Robert W.
Vancouver, BC
www.mwtech.com

"Juan T. Llibre" wrote:

Try this :

HttpBrowserCapabilities bc = Request.Browser;
Response.Write("<p>Browser Capabilities:</p>");
Response.Write("Type = " + bc.Type + "<br>");
Response.Write("Name = " + bc.Browser + "<br>");
Response.Write("Version = " + bc.Version + "<br>");
Response.Write("Major Version = " + bc.MajorVersion + "<br>");
Response.Write("Minor Version = " + bc.MinorVersion + "<br>");
Response.Write("Platform = " + bc.Platform + "<br>");
Response.Write("Is Beta = " + bc.Beta + "<br>");
Response.Write("Is Crawler = " + bc.Crawler + "<br>");
Response.Write("Is AOL = " + bc.AOL + "<br>");
Response.Write("Is Win16 = " + bc.Win16 + "<br>");
Response.Write("Is Win32 = " + bc.Win32 + "<br>");
Response.Write("Supports Frames = " + bc.Frames + "<br>");
Response.Write("Supports Tables = " + bc.Tables + "<br>");
Response.Write("Supports Cookies = " + bc.Cookies + "<br>");
Response.Write("Supports VB Script = " + bc.VBScript + "<br>");
Response.Write("Supports JavaScript = " + bc.JavaScript + "<br>");
Response.Write("Supports Java Applets = " + bc.JavaApplets + "<br>");
Response.Write("Supports ActiveX Controls = " + bc.ActiveXControls + "<br>");
Response.Write("CDF = " + bc.CDF + "<br>");


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
>I just added this line of code to a simple aspx page:
>
> HttpBrowserCapabilities browserCap = new HttpBrowserCapabilities();
>
> Yet when I used QuickWatch in Debug mode to inspect 'browserCap' all the
> properties were null. How come?
>
> --
> Robert W.
> Vancouver, BC
> www.mwtech.com
>



Apr 28 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

22 posts views Thread by Robert Bralic | last post: by
2 posts views Thread by kevinwjames | last post: by
14 posts views Thread by Anoop | last post: by
14 posts views Thread by webEater | last post: by
4 posts views Thread by =?Utf-8?B?Wm9sdA==?= | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.