Discovering Browser Capabilities ASP.NET and Web Forms: Developing Browser-Based Applications

296 The HTTP status text to be returned to the client browser. The type is String. The default is 200 OK . StatusCode The HTTP status code to be returned to the client browser. The type is Integer. The default is 200 . StatusDescription The HTTP status description to be returned to the client browser. The type is String. The default is OK . These are some commonly used methods of the HttpResponse class: Redirect Sends a redirect message to the client browser. Client browsers respond by requesting the web page specified in the redirect message. The syntax is: Public Sub RedirectByVal url As String The url parameter specifies the address of the new page to be requested. Write Writes a value directly to the output stream. This method is useful within script blocks that are embedded on the web page. There are versions of this method that write a single character, an array of characters, an object, and a string. The syntax for the version that writes a string is: Public Overloads Sub WriteByVal s As String

6.7 Discovering Browser Capabilities

One of ASP.NETs strengths is that it accommodates differences in client browsers without requiring any special effort from the application developer. However, it is often desirable for a web application to discover the capabilities of the browser making a given request. For this purpose, ASP.NET makes browser information available to the web application. ASP.NETs Request object available through the Page objects Request property has a Browser property that returns an object of type HttpBrowserCapabilities. The properties of this object are: ActiveXControls Indicates whether the client browser supports ActiveX controls. The type is Boolean. AOL Indicates whether the client browser is an America Online browser. The type is Boolean. BackgroundSounds Indicates whether the client browser supports background sounds. The type is Boolean. Beta 297 Indicates whether the client browser is a beta release. The type is Boolean. Browser Indicates the browser string e.g., IE received in the User-Agent header of the HTTP request. The type is String. CDF Indicates whether the browser supports Channel Definition Format for webcasting. The type is Boolean. ClrVersion Indicates the version of the .NET CLR installed on the client if any. The type is Version defined in the System namespace. Cookies Indicates whether the client browser supports cookies. The type is Boolean. Crawler Indicates whether the client browser is a web crawler an automated program used by online search engines to discover web content. The type is Boolean. EcmaScriptVersion Indicates the version of ECMA Script that the client browser supports. The type is Version defined in the System namespace. Frames Indicates whether the client browser supports Frames. The type is Boolean. JavaApplets Indicates whether the client browser supports Java applets. The type is Boolean. JavaScript Indicates whether the client browser supports JavaScript. The type is Boolean. MajorVersion Indicates the major version number of the client browser. The type is Integer. MinorVersion Indicates the minor version number of the client browser. The type is Double. For example, if the version of the client browser is 8.15, the value of the MinorVersion property is 0.15 . MSDomVersion 298 Indicates the version of the Microsoft XML document object model that the client browser supports. The type is Version defined in the System namespace. Platform Indicates the platform on which the client browser is running. The type is String. For example, for a browser running on Windows 2000 Professional, the Platform property returns WinNT . Tables Indicates whether the client browser supports HTML tables. The type is Boolean. Type Indicates the name and major version number of the client browser e.g., IE6 . The type is String. VBScript Indicates whether the client browser supports VBScript. The type is Boolean. Version Indicates the full version number of the client browser e.g., 8.15 . The type is String. W3CDomVersion Indicates the version of the W3C XML document object model that the client browser supports. The type is Version defined in the System namespace. Win16 Indicates whether the client browser is running on a 16-bit Windows operating system. The type is Boolean. Win32 Indicates whether the client browser is running on a 32-bit Windows operating system. The type is Boolean.

6.8 Maintaining State