๐ง 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.Browserobject 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
| Property | Description |
|---|---|
Browser | Browser name (e.g., Chrome, Firefox) |
Version | Version number (e.g., 118.0) |
MajorVersion | Integer part of version |
MinorVersion | Decimal part of version |
Platform | OS platform (e.g., WinNT, MacIntel) |
Cookies | Indicates if cookies are supported |
JavaScript | True if JavaScript is supported |
VBScript | True if VBScript is supported (IE only) |
Tables | Supports HTML tables |
Frames | Supports frames |
MobileDeviceModel | Model of mobile device if available |
Type | Full 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.inior.NET browserCapssettings. - 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.Browserto 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.Browserexposes properties likeBrowser,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 :
