ASP与CGI之间的参数传递

我想用VC写了一个CGI,用来接受另一ASP页面用POST方式传来的参数值。用VC有简单点的方法实现吗?
---------------------------------------------------------------

c/c++语言里可以通过环境变量可以接受来自客户端的数据,跟是否来自asp页面没关系。
找找msdn里的例子。
---------------------------------------------------------------

用参数直接传送给.cgi页面,cgi和asp都能通过诸如?aaa=aaa&bbb=bbb来传递参数。
---------------------------------------------------------------

两种递交get和post方式的处理不同:
给你一个经典代码:得自己编中文的解码
#include

 1<stdio.h>   
 2#include <stdlib.h>   
 3#include <string.h>   
 4char InputBuffer[4096];   
 5int main(int argc, char *argv[]) {   
 6int ContentLength; /*数据长度*/   
 7int x;   
 8int i;   
 9char *p;   
10char *pRequestMethod; /* METHOD属性值 */   
11setvbuf(stdin,NULL,_IONBF,0); /*关闭stdin的缓冲*/   
12printf("Content-type: text/html\n"); /*从stdout中输出,告诉Web服务器返回的信息类型*/   
13printf("\n"); /*插入一个空行,结束头部信息*/   
14/* 从环境变量REQUEST_METHOD中得到METHOD属性值 */   
15pRequestMethod = getenv("REQUEST_METHOD");   
16if (pRequestMethod==NULL) {   
17return 0;   
18}   
19if (_stricmp(pRequestMethod,"POST")==0) {   
20p = getenv("CONTENT_LENGTH"); /*从环境变量CONTENT_LENGTH中得到数据长度*/   
21if (p!=NULL) {   
22ContentLength = atoi(p);   
23} else {   
24ContentLength = 0;   
25}   
26if (ContentLength&gt;sizeof(InputBuffer)-1) {   
27ContentLength = sizeof(InputBuffer)-1;   
28}   
29i = 0;   
30while (i<contentlength) (_stricmp(prequestmethod,"get")="0)" (p!="NULL)" (x="EOF)" *从stdin中得到form数据*="" *从环境变量query_string中得到form数据*="" *具体译码和处理数据,该函数代码略*="" ;="" break;="" contentlength="i;" decodeandprocessdata();="" else="" if="" inputbuffer[i++]="x;" inputbuffer[i]="\0" p='getenv("QUERY_STRING");' printf("<head="" strncpy(inputbuffer,p,sizeof(inputbuffer));="" x="fgetc(stdin);" {="" }=""><title>Submitted OK</title>\n"); /*从stdout中输出返回信息*/   
31printf("<body>The information you supplied has been accepted.</body>\n");   
32return 0;   
33}   
34  
35  
36\---------------------------------------------------------------   
37  
38Post过来的自动作为环境变量处理getenv抓就可以。</contentlength)></string.h></stdlib.h></stdio.h>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus