Sideway
output.to from Sideway
Draft for Information Only

Content

ASP Server Components
  Browser Capabilities Component
    File Name
    Syntax
    Parameters
    Remark
   Browscap.ini File
    Syntax
    Parameters
   Examples
   Retrieving Browser Capabilities from a Cookie For IE

ASP Server Components

Some of the ASP server components are the common features found in dynamic web pages. These base ASP server components are provided to enrich the pre-made functions of ASP technology for making dynamic and interactive web pages. However, some IIS pre-made components are not installed for all version of IIS. Ad Rotator, Browser Capabilities, Content Linker, Content Rotator, Counters, Logging Utility, My Info, Page Counter, Status, and tools are not installed with IIS 6.0. However, if you upgrade your Web server from a previous version of IIS, the pre-made components are not removed. Some IIS pre-made components, ASP content rotator and nextlink,  are deprecated in IIS7. And most IIS pre-made components are either not installed with IIS7 or their usage is not supported.

Browser Capabilities Component

The Browser Capabilities Component can be used to create a BrowserType object that acts as a data collection in an ASP page for providing a description of the capabilities of the client's web browser to the ASP scripts. The function of the BrowserType object is to automate the checking of the capabilities of the user browser against the database each time when an user sents an HTTP request to open or reload the web page. A text file called browser.ini file is used to store the information about the capabilities of browsers. Both new properties or new browser definitions available in the market can be added to database by updating the Browscap.ini file. The mechanism of the function is made use of the HTTP User Agent header sent by the browser when connecting to the web server. The HTTP User Agent header is an ASCII string of the browser identifier and version number. The HTTP User Agent header is then used by the BrowserType object to compare with the entries in the Browscap.ini file. If the BrowserType object finds a matched entry in the Browscap.ini file, the properties of the matched browser in the Browsercap.ini is assumed to be the properties of the connected user Browser and is assigned to the properties of the BrowserType object accordingly. If the BrowserType object cannot find a matched entry for the HTTP User Agent header in the Browscap.ini file, the BrowserType object will try to search for the closest matched entry by using the * and ? wildcards. If the BrowserType object cannot find a closest matched entry for the HTTP User Agent header in the Browscap.ini file, the BrowserType object will use the default browser settings as the properties of the connected user browser if the default browser capability settings is defined in the Browscap.ini. When the BrowserType object cannot find a matched entry or a closest matched entry and default browser settings have not been specified in the Browscap.ini file, the BrowserType object sets every property to the string "UNKNOWN."

File Name

The file name of the Browser Capabilities component is Browscap.dll.

Syntax

Set BrowserTypeName = Server.CreateObject("MSWC.BrowserType")

Parameters

BrowserTypeName

The parameter "BrowserTypeName" is the name assigned to the instance of the BrowserType object created by the call using the Server.CreateObject.

Remark

The Browser Capabilities Component does not work with Internet Information Server 7 (IIS7).

Browscap.ini File

The Browscap.ini File is used to store the default properties of browser setting and the database entries of the properties of browsers for the Browser Capabilities Component. The default value of the properties of browser is used to set the properties of browser when there is no matched entry found in the Browscap.ini file. Any property definitions can be declared for any number of browser in the Browscap.ini file. Each browser definition entry should contain the HTTP User Agent header, and the associated property definitions, that is the name of properties and the corresponding value setting of the properties. For the format of the HTTP User Agent header, the HTTP specification can refer to http://www.w3.org/Protocols/Specs.html for details.

The Browscap.ini File should be stored in the same directory as  the Browscap.dll fille. Each parameter or setting is stroed in one single line. Comments is allowed anywhere  in the Browscap.ini by starting a new line with a semicolon ";", so that the whole line will be ignored by the BrowserType object.  The Browscap.ini File can be divided into two sections. One is for the data entries for any number of browsers. The other is for default entries for the default browser setting starting with the keyword "Default Browser Capability Settings"

The change in a Browscap.ini File may need to restart the IIS services in ordered to make the changes become effective.

Syntax

([; comments])*
([HTTPUserAgentHeader]
[parent = browserDefinition]
(propertyN = valueN)+)*
([Default Browser Capability Settings]
(defaultPropertyN = defaultValueN)+)?

Parameters

[...]

The parameter "[" & "]" is the indicator of the bracketed parameters by a pair of square brackets "[...]" is an optional item unless other specified.

(...)*

The parameter "*" is the indicator of the bracketed property parameters by a pair of brackets "(...)" can be repeated zero or more times.

(...)+

The parameter "+" is the indicator of the bracketed property parameters by a pair of brackets "(...)" can be repeated one or more times.

(...)?

The parameter "?" is the indicator of the bracketed property parameters by a pair of brackets "(...)" can be zero or one time

;

The optional parameter ";" is the indictor of a comment line placing on the starting of a line that will be ignored by the BrowserType object.

comments

The optional parameter "comments" is used to specify the content of a comment on the same line.

[HTTPUserAgentHeader]

The square bracketed parameter "HTTPUserAgentHeader" is used to specify the unique value of the HTTP user agent header of a browser that to be associated with the properties of browser declared in the property parameter. There can be zero or more browser entries in the Browscap.ine file , but each should be starting with a unique HTTPUserAgentHeader value.

When specifying the value in HTTPUserAgentHeader, a asterisk (*) character can be used as a wildcard character to replace zero or more characters and a question mark (?) character can be used as a wildcard character to replace a single character. For example, string in the HTTPUserAgentHeader:

[Mozilla/4.0 (compatible; MSIE 5.0;* Windows NT)]

can be used for matching with the user browsers:

[Mozilla/4.0 (compatible; MSIE 5.0; Windows NT)]
[Mozilla/4.0 (compatible; MSIE 5.0; AK; Windows NT)]
[Mozilla/4.0 (compatible; MSIE 5.0; SK; Windows NT)]

However, the BrowserType object will attempt to match the HTTP User Agent header of the user browser to the value HTTPUserAgentHeader exactly first. if that fails, the BrowserType object will continue the matching process with wildcard characters. When applying the wildcard character, the BrowserType object uses the closest match strategy, the matching of the HTTP User Agent header value of the user browser with the fewest characters replacement to select the closest entry of in the Browscap.ini. Therefore when more than one HTTPUserAgentHeader in the Browscap.ini containing wildcard characters is matched with the HTTP User Agent header of the user browser, the BrowserType object will only return the properties of the HTTPUserAgentHeader entry of closest match.

browserDefinition

The optional parameter "browserDefinition" is used to specify the "HTTP User Agent header" string of a browser that to be referenced as the parent browser. When the optional parameter "browserDefinition" is specified, the properties of the current specified browser will inherit all of the property values declared in the parent browser's definition. And values of these inherited properties can be replaced by a new value through setting the corresponding parameter propety explicitly. These optional parameter is mainly used for defining a new version of a browser from the previous version because a new version usually retains most of the properties of the previous release.

propertyN

The optional parameter "propertyN" is used to specify the name of a browser property that to be set. The name of a browser property must be started with an alphabetic character and cannot excess 255 characters. some possible properties are:

ActiveXControls: to specify supporting ActiveX Controls or not
Backgroundsounds: to specify supporting background sounds or not
Beta: to specify the browser is beta software or not
Browser: to specify the name of the browser
Cdf: to specify supporting the Channel Definition Format for Webcasting or not
Cookies: to specify supporting cookies or not
Frames: to specify supporting frames or not
Javaapplets: to specify supporting Java applets or not
Javascript: to specify supporting JScript or not
Majorver: to specify the major version number of the browser
Minorver: to specify the minor version number of the browser
Parent: to specify the parent browser as defined in Browscap.ini
Platform: to specify the name of the operation system of the browser running on
Tables: to specify supporting tables or not
Vbscript: to specify supporting VBScript or not
Version: to specify the version number of the browser

In the Browscap.ini file, the number of statements of property values can be specified as many as needed in each browser entry. But the Browscap.ini file can also contain only the properties which are needed by the application and should be known whether the user browser supported or not. For example, if an application only supports a Cookies supported browser, the Browscap.ini file only needs one property statment for each browser entry.

[Default Browser Capability Settings]

The square bracketed parameter "Default Browser Capability Settings" is used to specify the unique value of the HTTP user agent header of the default browser that to be associated with the properties of the default browser declared in the property parameter. There can only be one default browser entry in the Browscap.ine file. Usually a single asterisk (*) character is used as the HTTP user agent header for the default browser capability settings so that the default property settings can be applied to any user browser when there is no closest entry is found in the "HTTPUserAgentHeader" section.

Examples

  • Example of making use of BrowserType object to display some of the capabilities of the current browser in a table.

    ASP Page, BrowserType.asp:

    <%
    Set br = Server.CreateObject("MSWC.BrowserType")
    %>
    <TABLE BORDER=1 CELLPADDING=4>
       <TR>
       <TD>ActiveX Controls</TD>
       <TD><%= br.ActiveXControls %></TD>
       </TR>
       <TR>
       <TD>BackgroundSounds</TD>
       <TD><%= br.BackgroundSounds %></TD>
       </TR>
       <TR>
       <TD>Browser</TD>
       <TD><%= br.browser %>
       </TR> 
       <TR>
       <TD>Cookies</TD>
       <TD><%= br.cookies %></TD>
       </TR>
       <TR>
       <TD>Frames</TD>
       <TD><%= br.frames %></TD>
       </TR>
       <TR>
       <TD>JScript</TD>
       <TD><%= br.javascript %></TD>
       </TR>
       <TR>
       <TD>Tables</TD>
       <TD><%= br.tables %></TD>
       </TR>
       <TR>
       <TD>VBScript</TD>
       <TD><%= br.vbscript %></TD>
       </TR>
       <TR>
       <TD>Version</TD>
       <TD><%= br.version %></TD>
       </TR>
    </TABLE>

    HTML web page ouput:
    ActiveX Controls False
    BackgroundSounds False
    Browser Default    
    Cookies False
    Frames False
    JScript False
    Tables True
    VBScript False
    Version 0.0
  • Example of Browscap.ini File with parent tag and default browser settings

    Text in the Browscap.ini File, Browscap.ini:

    ;;ie 5.0
    [IE 5.0]
    ActiveXControls=TRUE
    backgroundsounds=TRUE
    beta=False
    browser=IE
    cookies=TRUE
    frames=TRUE
    javaapplets=True
    javascript=TRUE
    majorver=#5
    minorver=#0
    tables=TRUEE
    vbscript=TRUE
    Version=5.0
    Win16=False
    AK=False
    SK=False
    AOL=False

    ;;ie 5.x
    [Mozilla/4.0 (compatible; MSIE 5.*; Windows NT)]
    minorver=0
    parent=IE 5.0
    platform=WinNT
    version=5.00

    ; Default Browser Settings
    [*]
    browser=Default
    frames=FALSE
    tables=TRUE
    cookies=FALSE
    backgroundsounds=FALSE
    vbscript=FALSE
    javascript=FALSE

Retrieving Browser Capabilities from a Cookie For IE

In IIS 5.0, the client capabilities can be determined through retrieving a cookie, BrowsCap, describing browser capabilities of the user obtained by the javascript STYLE behavior as part of the request from the client initiated by a METADATA#metatag, the ASP page can then create an instance of the Browser Capabilities component that adds the name value pairs specified by the cookie as properties of the BrowserType object.

However, this technique does not work with file redirected from Server.Transfer or Server.Execute methods because the METADATA#metatag in the redirected file will be ignored by the IIS if the file is a redirection from a Server.Transfer or Server.Execute methods and while other parts of the file will be processed normally.

For example, a file, createcap.asp is used to create an instance of the BrowserType object of the browser capabilities of the user browser and display the browser capabilities of the user browser on the web page. In order to retrieving the cookie from the user browser, an additional file, getcookie.htm is needed to run on the client and determine the list of browser capability properties of the client using DHTML. And the technique used to run the file, getcookie.htm automatically on the client is by inserting a METADATA#metatag before running the contents of the file.

Browser Capabilities displaying ASP Page, createcap.asp:

<!--METADATA TYPE="Cookie" NAME="BrowsCap" SRC="getcookie.htm"-->
<HTML>
<BODY>
<% Set br = Server.CreateObject("MSWC.BrowserType") %>
<%
Response.write("width= "+br.width+ "<BR />")
Response.write("height= "+br.height+ "<BR />")
Response.write("bufferDepth= "+br.bufferDepth+ "<BR />")
Response.write("colorDepth= "+br.colorDepth+ "<BR />")
Response.write("cookies= " +CStr(br.cookies)+ "<BR />")
Response.write("platform= "+br.platform+ "<BR />")
%>
</BODY>
</HTML>

Browser Capabilities retrieving WebASP Page,  getcookie.htm:

<HTML>
<SCRIPT language="JavaScript">
function removeErrors()
{
// Remove all errors.
return true;
}
window.onerror = removeErrors;
function window.onload ()
{
bdBrowsCap.style.behavior = "url(#default#clientCaps)";
brString = "width= " + bdBrowsCap.width;
brString += "&height= " + bdBrowsCap.height;
brString += "&bufferDepth= " + bdBrowsCap.bufferDepth;
brString += "&colorDepth= " + bdBrowsCap.colorDepth;
brString += "&cookies= " +bdBrowsCap.cookieEnabled;
brString += "&platform= " + bdBrowsCap.platform;
document.cookie = "BrowsCap= " + brString;
}
</SCRIPT>
</HEAD>
<BODY ID="bdBrowsCap">
</BODY>
</HTML>


©sideway

ID: 130200005 Last Updated: 2/11/2013 Revision: 0 Ref:

close

References

  1. Active Server Pages,  , http://msdn.microsoft.com/en-us/library/aa286483.aspx
  2. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
  3. ASP Best Practices,  , http://technet.microsoft.com/en-us/library/cc939157.aspx
  4. ASP Built-in Objects,  , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
  5. Response Object,  , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
  6. Request Object,  , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
  7. Server Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
  8. Application Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
  9. Session Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
  10. ASPError Object,  , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
  11. ObjectContext Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
  12. Debugging Global.asa Files,  , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
  13. How to: Debug Global.asa files,  , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
  14. Calling COM Components from ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
  15. IIS ASP Scripting Reference,  , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
  16. ASP Keywords,  , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
  17. Creating Simple ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
  18. Including Files in ASP Applications,  , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
  19. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
  20. FileSystemObject Object,  , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  , ADO Object Model
  22. ADO Fundamentals,  , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx
close

Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019