Converting Environment Variables

CGI applications often make use of information residing in environment variables. These variables contain information about the web server itself or about the HTTP request sent by the client browser. In CGI written in Perl, these variables' values are retrieved from the %ENV associative array. In WinCGI written using O'Reilly's CGI framework for Visual Basic programmers, these values are retrieved from the contents of global variables made available by the CGI.BAS or CGI32.BAS code modules.

Active Server Pages applications also make use of these variables. In ASP, this information is retrieved from the Request object's ServerVariables collection. Table 2.2 will help you convert your CGI environment variables to ASP, while Table 2.3 will aid in converting WinCGI to ASP. Note that the general syntax required to retrieve the ASP variable is:

               varname = Request.ServerVariables("ASP_Variable")

Note also that there are other environment-type variables available to ASP applications that are not available to CGI or WinCGI.

Table B.2. Converting CGI Environment Variables to ASP Variables

CGI Environment Variable

ASP Variable

Description

AUTH_TYPE

AUTH_TYPE

Authentication method used to validate user.

CONTENT_LENGTH

CONTENT_LENGTH

Length of the query data (in bytes or number of characters) passed through standard input to the CGI application.

CONTENT_TYPE

CONTENT_TYPE

The media type of the query data (for example "text/html") sent ...

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.