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




Authentication method used to validate user.



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



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

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.