ISAPI (Internet Server API) was initially a CGI application development interface provided by Microsoft for the IIS Server. Its main purpose is to provide a good development interface for CGI development, if ISAPI is not responsible, it can be considered as a development mode similar to WinCGI, except that ISAPI obtains parameters transmitted by user forms through ing macros. This is similar to the Message ing macro of MFC.
Of courseThe launch of ISAPI also has many other features:
- ISAPI is implemented through DLL dynamic connection library. Therefore, it is faster to load normal EXE programs, and the system will not immediately remove the DLL space in the memory after use, therefore, it will get a faster speed when used again.
- The ISAPI runs in the thread mode inside the caller, so it requires less runtime space than the CGI process.
- In the sameIn DLL, multiple processing functions can be centralized, and different functions can process different requests by ing macros.
- SinceIIS integration, so you can use ISAPI to develop ISAPI filters. You can use a filter to perform functions such as user permission detection, data encryption, compression, and logs. The functions of the IIS server can also be enhanced using the ISAPI filter.
So far, many non-The WEB servers of M $ are also added with ISAPI support.
In the sameThe DLL can contain multiple processing functions in a centralized manner. Therefore, there is a difference between ISAPI execution requests and general CGI execution requests. In the URL, you must enter the following form: http ://... /cgi-bin/test. dll? Function_name & name = xxx & email = yyy, function_name indicates the function name. to be correct, you must map it to a handler in the DLL. A default function is used to process unmapped functions.
VC4.2 and later versions provide a Wizard for creating an ISAPI program. When creating a project, select ISAPI Extension Wizard and select create Server Extension and enter relevant information in the subsequent dialog box.The simplestThe ISAPI contains at least one new class derived from the CHttpServer class, and performs basic ing in the class. The BOOL GetExtensionVersion (HSE_VERSION_INFO * pVer) is overloaded) function and a member function in the form of void Default (CHttpServerContext * pCtxt. Fortunately, the Wizard program has done everything for us and created the most basic code.
The Default function is used to process code in the Default function without parameters. First, we modify the relevant Code as follows:
Void CTestisaExtension: Default (CHttpServerContext * pCtxt)
{
// Print the <HTML> <BODY> tags.
StartContent (pCtxt );
// Print the title.
WriteTitle (pCtxt );
* PCtxt <_ T ("<p> demo </p> ");
* PCtxt <_ T ("<p> currently the Default member function </p> ");
// Print </HTML> </BODY> tags.
EndContent (pCtxt );