๐Ÿงฐ Common ASP References (Shared)
Estimated reading: 4 minutes 57 views

๐Ÿง  ASP โ€“ BrowserCap โ€“ Detect and Handle Browser Capabilities in Classic ASP

๐Ÿงฒ Introduction โ€“ What Is BrowserCap in ASP?

BrowserCap (Browser Capabilities) is a Classic ASP feature used to detect client browser details, such as the browser name, version, platform, JavaScript support, screen resolution, and more. This is accomplished via the Request.Browser object, which reads information from the browsercaps section of IIS configuration (or browscap.ini in older versions).

๐ŸŽฏ In this guide, youโ€™ll learn:

  • What the Request.Browser object is and how it works
  • Properties you can read (browser, version, capabilities)
  • Real-world examples for user targeting
  • Best practices and output examples

๐Ÿ“‹ Syntax โ€“ Using Request.Browser

<%
Dim browser
Set browser = Request.Browser

Response.Write "Browser: " & browser.Browser & "<br>"
Response.Write "Version: " & browser.Version & "<br>"
Response.Write "Platform: " & browser.Platform & "<br>"
Response.Write "JavaScript Enabled: " & browser.JavaScript
%>

๐Ÿ”Ž Commonly Used Properties

PropertyDescription
BrowserBrowser name (e.g., Chrome, Firefox)
VersionVersion number (e.g., 118.0)
MajorVersionInteger part of version
MinorVersionDecimal part of version
PlatformOS platform (e.g., WinNT, MacIntel)
CookiesIndicates if cookies are supported
JavaScriptTrue if JavaScript is supported
VBScriptTrue if VBScript is supported (IE only)
TablesSupports HTML tables
FramesSupports frames
MobileDeviceModelModel of mobile device if available
TypeFull browser string, e.g., “Chrome118”

๐Ÿงช Full Output Example

<%
Dim b
Set b = Request.Browser

Response.Write "<h3>Browser Capabilities:</h3>"
Response.Write "Browser: " & b.Browser & "<br>"
Response.Write "Version: " & b.Version & "<br>"
Response.Write "Platform: " & b.Platform & "<br>"
Response.Write "JavaScript: " & b.JavaScript & "<br>"
Response.Write "Cookies Enabled: " & b.Cookies & "<br>"
Response.Write "Supports VBScript: " & b.VBScript & "<br>"
Response.Write "Device: " & b.MobileDeviceModel
%>

๐Ÿงช Output Example (for Chrome on Windows):

Browser: Chrome  
Version: 118.0  
Platform: WinNT  
JavaScript: True  
Cookies Enabled: True  
Supports VBScript: False  
Device:

๐Ÿ“ How It Works Behind the Scenes

  • ASP reads browser details using User-Agent string from the request header.
  • The mapping is done via IIS configuration in browscap.ini or .NET browserCaps settings.
  • If a browser is not recognized, it falls back to default values.

๐Ÿง˜ Real-World Use Cases

  • Showing mobile-friendly versions of the site
  • Warning users about unsupported browsers
  • Customizing layout/UI based on JS or frames support
  • Debugging client compatibility for legacy web apps

๐Ÿงพ Example โ€“ Redirect Old Browsers

<%
If Request.Browser.MajorVersion < 10 Then
    Response.Redirect "upgrade-browser.asp"
End If
%>

๐Ÿ“Œ Useful for enforcing modern browser compatibility.


๐Ÿ“˜ Best Practices for Using BrowserCap

โœ… Do:

  • Use Request.Browser to gracefully degrade features
  • Fallback to general user-agent parsing when unknown
  • Log values for analytics or debugging

โŒ Avoid:

  • Relying solely on BrowserCap for mobile detection
  • Hardcoding browser checks โ€“ use capability checks instead
  • Trusting properties without testing on multiple devices

๐Ÿ“Œ Summary โ€“ Recap & Next Steps

The BrowserCap feature in Classic ASP helps you identify client capabilities like browser type, version, JavaScript, and cookies. This enables smart content rendering and compatibility decisions based on browser features.

๐Ÿ” Key Takeaways:

  • Request.Browser exposes properties like Browser, Version, JavaScript, Cookies
  • Use it for targeting, UI adjustments, or feature fallback
  • Check version and platform before applying conditional logic

โš™๏ธ Real-world Use Cases:

  • Redirect outdated browsers
  • Disable dynamic scripts on unsupported platforms
  • Display alternative UI for older or mobile clients

โ“ FAQs โ€“ ASP BrowserCap


โ“ Where does Request.Browser get its information?
โœ… From the IIS browscap.ini or ASP.NET’s browserCaps section (based on the User-Agent header).


โ“ Is BrowserCap accurate for modern browsers?
โœ… It can be limited. For full modern detection, use JavaScript or external detection libraries.


โ“ Can I customize browser definitions?
โœ… Yes. You can update the browscap.ini file on your server or modify .NET browserCaps settings.


Share Now :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

๐Ÿง  ASP โ€“ BrowserCap

Or Copy Link

CONTENTS
Scroll to Top