CGI Input and Output in .NET

Drawer PDF417 in .NET CGI Input and Output
CGI Input and Output
Decode PDF417 In Visual Studio .NET
Using Barcode Control SDK for .NET framework Control to generate, create, read, scan barcode image in VS .NET applications.
There are many ways a Web server can receive information from a client (such as a Web browser) The HTTP protocol defines the way in which a Web server and a client can exchange information The most common methods of transmitting request data to a Web server are GET requests and POST requests, which I describe in the following sections
PDF 417 Printer In VS .NET
Using Barcode creator for VS .NET Control to generate, create PDF417 image in VS .NET applications.
12 Running CGI Scripts
PDF417 Scanner In Visual Studio .NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in VS .NET applications.
GET requests
Make Barcode In .NET Framework
Using Barcode generator for VS .NET Control to generate, create bar code image in .NET applications.
The GET request is the simplest method for sending HTTP request Whenever you enter a Web site address in your Web browser, it generates a GET request and sends it to the intended Web server For example, if you enter http: //wwwhungryminds com in your Web browser, it sends an HTTP request such as the following:
Bar Code Reader In .NET
Using Barcode scanner for .NET framework Control to read, scan read, scan image in .NET framework applications.
GET /
PDF417 Printer In Visual C#
Using Barcode maker for .NET Control to generate, create PDF417 image in Visual Studio .NET applications.
to the wwwhungrymindscom Web server This GET request asks the Hungry Minds Web server to return the top-level document of the Web document tree This document is often called the home page, and usually refers to the indexhtml page in the top-level Web directory Furthermore, HTTP enables you to encode additional information in a GET request For example:
PDF 417 Generator In .NET
Using Barcode creation for ASP.NET Control to generate, create PDF417 image in ASP.NET applications.
http://wwwmycompanycom/cgi-bin/searchcgi books=cgi&author=kabir
Draw PDF417 In Visual Basic .NET
Using Barcode encoder for .NET Control to generate, create PDF417 image in VS .NET applications.
Here, the GET request is:
Drawing GS1 - 12 In VS .NET
Using Barcode printer for .NET Control to generate, create UPCA image in .NET framework applications.
GET wwwmycompanycom/cgi-bin/searchcgi books=cgi&author=kabir
Draw Bar Code In VS .NET
Using Barcode generation for VS .NET Control to generate, create bar code image in .NET applications.
This tells the server to execute the /cgi-bin/searchcgi CGI program and pass to it the books=cgi and author=kabir input data When a CGI-compliant Web server such as Apache receives this type of request, it follows the CGI specifications and passes the input data to the application (in this case, the searchcgi in the cgi-bin directory) When a CGI resource is requested via an HTTP GET request method, Apache: 1 Sets the environment variables for the CGI program, which includes storing the HTTP request method name in an environment variable called REQUEST_METHOD, and the data received from the client in an environment variable called QUERY_STRING 2 Executes the requested CGI program 3 Waits for the program to complete and return output 4 Parses the output of the CGI program if it is not a nonparsed header program (A nonparsed header CGI program creates its own HTTP headers so that the server does not need to parse the headers) 5 Creates necessary HTTP header(s) 6 Sends the headers and the output of the program to the requesting client Figure 12-2 illustrates this process Now let s look at what a CGI program has to do to retrieve the input to use it for its internal purposes
Drawing EAN 13 In Visual Studio .NET
Using Barcode maker for .NET framework Control to generate, create European Article Number 13 image in VS .NET applications.
Part III Running Web Applications
Draw British Royal Mail 4-State Customer Barcode In VS .NET
Using Barcode creator for VS .NET Control to generate, create RM4SCC image in .NET applications.
Apache Server Internet
Printing Barcode In Visual Studio .NET
Using Barcode maker for ASP.NET Control to generate, create barcode image in ASP.NET applications.
Setup CGI Environment Variables GET
Paint Data Matrix In Visual Studio .NET
Using Barcode drawer for ASP.NET Control to generate, create Data Matrix ECC200 image in ASP.NET applications.
/cgi-bin/searchcgi book=cgi&author=kabir
Data Matrix ECC200 Recognizer In .NET Framework
Using Barcode recognizer for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
Execute CGI Program /cgi-bin/searchcgi
Barcode Drawer In Java
Using Barcode creator for Java Control to generate, create bar code image in Java applications.
CGI Program Complete
Data Matrix 2d Barcode Generation In Java
Using Barcode creation for Java Control to generate, create ECC200 image in Java applications.
Parse Output (if not non-parsed CGI)
Draw Code 128 Code Set B In C#
Using Barcode creation for VS .NET Control to generate, create Code 128C image in .NET framework applications.
Create HTTP Header
Print USS Code 39 In Visual C#
Using Barcode generation for VS .NET Control to generate, create USS Code 39 image in .NET applications.
Return Header & CGI Content
Barcode Printer In .NET
Using Barcode generation for ASP.NET Control to generate, create barcode image in ASP.NET applications.
Figure 12-2: CGI server processing
As Figure 12-3 shows, a CGI program 1 Reads the REQUEST_METHOD environment variable 2 Determines whether the GET method is used or not by using the value stored in the REQUEST_METHOD variable 3 Retrieves the data stored in the QUERY_STRING environment variable, if the GET method is used 4 Decodes the data 5 Processes the decoded data as it pleases 6 Writes the Content-Type of the output to its standard output device (STDOUT) after processing is complete 7 Writes the output data to the STDOUT and exits The Web server reads the STDOUT of the application and parses it to locate the Content-Type of the output It then transmits appropriate HTTP headers and the Content-Type before transmitting the output to the client The CGI program is exited and the entire CGI transaction is completed
12 Running CGI Scripts
START
Read Environment Variable REQUEST_METHOD
Figure 12-3: CGI program processing
is GET method used
Read Environment Variable QUERY_STRING
Decode Data
Process
Output Content Type to STDOUT
Output Contents to STDOUT
Note
If a CGI program is to provide all of the necessary HTTP headers and Content-Type information itself, its name has to be prefixed by nph (which stands for nonparsed header) An nph CGI program s output is not parsed by the server and transmitted to the client directly; most CGI programs let the server write the HTTP header and are, therefore, parsed header programs
Using the GET request method to pass input data to a CGI program is limiting in many ways, including these ways: The total size of data that can be transmitted as part of a URL is limited by the client s URL-length limit Many popular Web browsers have hard limits for the length of a URL, and therefore, the total data that can be sent via an encoded URL is quite limited However, on occasion it might be a good idea to pass data to CGI programs via a URL For example, if you have an HTML form that uses the GET method to send data to a CGI program, the submitted URL can be bookmarked for later use without going through the data-entry form again This can be a user-friendly feature for database-query applications