Does HttpBrowserCapabilities work?

G

Guest

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?
 
J

Juan T. Llibre

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>");
 
J

Juan T. Llibre

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!




Robert W. said:
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 said:
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>");
 
B

bruce barker \(sqlwork.com\)

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 said:
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!




Robert W. said:
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 said:
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>");





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?
 
J

Juan T. Llibre

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.

;-)






bruce barker (sqlwork.com) said:
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 said:
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!




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



:

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>");





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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top