ServerSide Web Programming with Active Server Pages Browser

  • Slides: 9
Download presentation
Server-Side Web Programming with Active Server Pages Browser Capabilities Component 9/26/2020 © 2000, Valtara

Server-Side Web Programming with Active Server Pages Browser Capabilities Component 9/26/2020 © 2000, Valtara Digital Design/Blitzkrieg Software 1

Browser Capabilities Component (BCC) • Many reasons for detecting client’s browser capabilities • Client-side

Browser Capabilities Component (BCC) • Many reasons for detecting client’s browser capabilities • Client-side Javascript most efficient for simple, obvious queries (e. g. browser version) • ASP’s BCC more robust for detailed queries like frames, Javascript support, etc. • Most important for support of older browsers that don’t support some HTML features, but… 9/26/2020 © 2000, Valtara Digital Design/Blitzkrieg Software 2

How It Works • Webserver retrieves from the HTTP USER AGENT header sent by

How It Works • Webserver retrieves from the HTTP USER AGENT header sent by client’s browser. Mozilla/4. 0 (compatible; MSIE 4. 01; Windows 95) Mozilla/4. 0 (compatible; MSIE 5. 0; Windows 98; Dig. Ext) • ASP matches the header to entries located in a special file called Brows. Cap. ini that lists capabilities of browsers. • List of capabilities loaded as properties of the BCC. • Via code webserver queries BCC properties to determine browser’s capabilities. 9/26/2020 © 2000, Valtara Digital Design/Blitzkrieg Software 3

Review - HTTP Fundamentals • Server receives requests from browser/client for resources – A

Review - HTTP Fundamentals • Server receives requests from browser/client for resources – A resource is any chunk of information that can be identified by a URL like HMTL or image files, scripts, streaming media, etc. • • Server retrieves and/or processes the resource Server sends the resource back to the client Server logs the transaction Responses/requests occur using the HTTP protocol, typically on port 80 9/26/2020 © 2000, Valtara Digital Design/Blitzkrieg Software 4

Sample HTTP Exchange To retrieve the resource at http: //www. host. com/path/file. html Browser

Sample HTTP Exchange To retrieve the resource at http: //www. host. com/path/file. html Browser sends request to host www. host. com, port 80: GET /path/file. html HTTP/1. 0 From: [email protected] com User-Agent: Mozilla/4. 0 (compatible; MSIE 5. 0) The server sends a response back to the client: HTTP/1. 0 200 OK Date: Fri, 31 Dec 1999 23: 59 GMT Content-Type: text/html Content-Length: 1354 [other header information…] <html><body><h 1>Happy New Millenium!</h 1> (more file contents) </body> </html> 9/26/2020 © 2000, Valtara Digital Design/Blitzkrieg Software 5

Sample Brows. Cap. ini Entry ; ; Netscape 4. 0 [Netscape 4. 0] browser=Netscape

Sample Brows. Cap. ini Entry ; ; Netscape 4. 0 [Netscape 4. 0] browser=Netscape version=4. 0 majorver=#4 minorver=#0 frames=TRUE tables=TRUE cookies=TRUE backgrounds=FALSE vbscript=FALSE javascript=TRUE javaapplets=TRUE Active. XControls=FALSE beta=False 9/26/2020 comment User. Agent HTTP Header Prefix integers with # © 2000, Valtara Digital Design/Blitzkrieg Software 6

Using the BCC • Keep webserver’s Brows. Cap. ini current. – Located in Win.

Using the BCC • Keep webserver’s Brows. Cap. ini current. – Located in Win. NTSystem 32inetsrv for IIS 4 – Updates at http: //www. cyscape. com/browscap/ • In ASP page, instantiate object & call its properties: <% Dim obj. BC Set obj. BC = Server. Create. Object(“MSWC. Browser. Type”) … Response. write “Table Support: “ & obj. BC. tables %> 9/26/2020 © 2000, Valtara Digital Design/Blitzkrieg Software 7

Notes • You can create custom properties in your Brows. Cap. ini file for

Notes • You can create custom properties in your Brows. Cap. ini file for greater detail. • If you call an undefined property, BCC will return the string “Unknown”. • Best coding practices should include closing instantiated objects after their use: set obj. BC = nothing 9/26/2020 © 2000, Valtara Digital Design/Blitzkrieg Software 8

New is ASP 3. 0 • BCC can only tell what that browser type

New is ASP 3. 0 • BCC can only tell what that browser type is capable of, not what the client’s specific browser is configured for (e. g. , cookies) • BCC can now receive a cookie from the client that details the client capabilities (cookie support, bandwidth, etc. ) • A client-side script is added that uses IE’s client. Caps behavior to generate a cookie. • Cookie is sent to the ASP page loaded into the BCC. • Feature works ONLY with IE 5. • See: http: //msdn. microsoft. com/workshop/Author/clientcaps/overview. asp 9/26/2020 © 2000, Valtara Digital Design/Blitzkrieg Software 9