Determining Client Capabilities
One of the more significant design decisions to make is how an application handles different client capabilities. For example, one of the most important issues for users is the speed of the connection. If your application can determine this speed, it can adjust the response to match that capacity. The only way for an application to be aware of the current connection speed is if the client includes this information as part of its request. Another important issue is to learn the type and version of browser that the client is using because some older browsers do not support features such as cookies, Java applets, and so on.
You can solve the client capabilities problem on either the client side or server side.
Determining Client Capabilities on the Client Side
The client-side solution relies on Dynamic HTML (DHTML) to include a description of the client's current configuration as part of the request.
The benefits of this approach include:
Reduction in roundtrips between the client and server.
Reduced load on the server.
Improved application responsiveness due to proxy server caching technology.
There are some situations where client-side scripting will not be feasible. For example, applications that are exposed on the Internet cannot guarantee that the client will support scripting, which means the applications may fail for some clients. In addition, server-side resources may not be accessible from the client side, as the client may reside on a network that does not allow scripting for security reasons.
Determining Client Capabilities on the Server Side
The server-side solution relies on the server variable that contain information about what features the client browser supports. For example, the HTTP_ACCEPT server variable contains a list of file formats that the client accepts. The HTTP_ACCEPT_LANGUAGE server variable contains the language of the browser. The HTTP_USER_AGENT server variable describes the browser, for example, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705)".
The following example shows you how to use the VBScript scripting language to determine if the client browser supports frames. Internet Explorer (IE) versions 1.5, 2.0, and certain versions of Mozilla did not support frames.
<% @Language="VBScript" %>
<%
Dim sUserAgent
Dim bFramesSupported
bFramesSupported = True
sUserAgent = Request.ServerVariables("HTTP_USER_AGENT")
If (0 < InStr( sUserAgent, "IE 1.5")) Then
bFramesSupported = False
ElseIf (0 < InStr( sUserAgent, "IE 2.0")) Then
bFramesSupported = False
ElseIf (0 < InStr( sUserAgent, "Microsoft Pocket Internet Explorer/0.6")) Then
bFramesSupported = False
ElseIf (0 < InStr( sUserAgent, "Mozilla/1.1")) Then
bFramesSupported = False
ElseIf (0 < InStr( sUserAgent, "Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; Smartphone; JavaScript")) Then
bFramesSupported = False
End If
If bFramesSupported Then
Response.Redirect("MyFramedPage.asp")
Else
Response.Redirect("MyNonFramedPage.asp")
End If
%>
An easier way to determine all client capabilities is to use the BrowsCap.dll COM component that comes installed with IIS. This component comes with a BrowsCap.ini file that contains a list of common browser user agent strings and their capabilities.