C# CGI程序
一、控制面板—>程序和功能—>打开或关闭Windows功能
把相关的功能勾上,点“确定”
二、新建一个网站,配置ISAPI和CGI限制、处理程序映射
三、CGI控制台应用程序代码:
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading; namespace CGI
{
class Program
{
static int i = ; static void Main(string[] args)
{
Thread thread = new Thread(new ParameterizedThreadStart(delegate(object obj)
{
while (true)
{
if (i < )
{
i++;
Thread.Sleep();
}
else
{
string queryStr = Environment.GetEnvironmentVariable("QUERY_STRING");
string[] paramArr = queryStr.Split('&');
string[] keyValue = paramArr[].Split('='); Console.Write("Content-Type: text/html;charset=GB2312;\n\n");
Console.Write("{\"d\":\"您传入的参数为:" + keyValue[] + ",输出结果为:" + i + "\"}");
Environment.Exit();
}
}
}));
thread.Start();
} // end of Main
} // end of Program
}
四、Web程序页面代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CGITest.aspx.cs" Inherits="Web监听.CGITest" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="/JS/easyui/easyui.css" rel="stylesheet" type="text/css" />
<script src="/JS/jquery.min.js" type="text/javascript"></script>
<script src="/JS/easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/JS/SimpoWindow.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$.ajax({
type: "get",
url: "http://localhost:160/cgi.exe?data=abcd",
dataType: "json",
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#msg").html(textStatus);
},
success: function (data, textStatus) {
$("#msg").html(data.d);
}
}); //倒计时
UpdateTime(10);
}); //倒计时
function UpdateTime(n) {
if ($("#msg").html().indexOf("请等待") != -1) {
$("#msg").html("请等待(" + n + ")......"); if (n > 0) {
setTimeout(function () {
UpdateTime(n - 1);
}, 1000);
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="msg" style="text-align: center; vertical-align: middle;">
请等待......
</div>
</form>
</body>
</html>
C# CGI程序的更多相关文章
- Apache运行python cgi程序
Apache运行python cgi程序 环境 win10 x64 专业版 Apache2.4 python 2.7 Apache安装和配置 Apache服务器的安装请自行搜索.在Apache2.4中 ...
- cgic 写CGI程序
CGIC是C语言CGI库函数,用于编写CGI程序 CGIC 主要完成以下功能: * 对数据进行语法分析 * 接收以 GET 和 PSOT 两种方式发送的数据 * 把 FORM 中的不同域连接成连续的串 ...
- C、Shell、Perl基于Tomcat开发CGI程序环境配置
基于Tomcat7.0版本号配置CGI开发环境,步聚例如以下: 以我的Tomcat7安装文件夹为例:TOMCA_HOME = /Users/yangxin/Documents/devToos/java ...
- httpd cgi程序配制+.py .cgi执行
vi /etc/httpd/conf/httpd.conf httpd默认首页配制: DirectoryIndex index.html index.html.var 首页的位置定义: Docume ...
- 使用c语言编写cgi程序
http://blog.chinaunix.net/uid-22566367-id-3109877.html 简单的说,cgi是沟通HTML表单和服务器端程序的接口,是可以被其他语言所应用的一个规范集 ...
- 教你用shell写CGI程序
以前用shell写过一些cgi的例子.今天向大家介绍一下. CGI是一种接口的标准,并不区分编程语言,也就是说,CGI可以用任何一种语言编写,只要这种语言具有标准输入.输出和环境变量.CGI会将标准输 ...
- 写一个CGI程序并运行
准备Linux和Apache我在/var/www/cgi-bin/下建一个文件get.c #include <stdio.h> #include <stdlib.h> int ...
- 第一个CGI程序-----完全就是普通的c语言嘛‘(*∩_∩*)′
第一个CGI程序 ----完全就是普通的C语言嘛 '(*∩_∩*)′ PainterQ 2017年5月14日 上一篇博文里面叙述了Apache的安装和配置方法,恍恍惚惚我就拥有了自己的第一个http ...
- 编写CGI程序步骤
CGI common gateway interface 可以让一个客户端,从网页浏览器向服务器请求数据, 这是描述客户端和服务器程序之间传输数据的一种标准. CGI是运行在服务器上的程序,提供同客户 ...
- C语言写CGI程序
一.CGI概述 CGI(公用网关接口)规定了Web服务器调用其他可执行程序(CGI程序)的接口协议标准.Web服务器通过调用CGI程序实现和Web浏览器的交互, 也就是CGI程序接受Web浏览器发送给 ...
随机推荐
- 熟用js中的Date
js中的Date类型是使用UTC(国际协调时间)自1970年1月1日午夜(零时)开始,经过的毫秒数来保存日期. 1. 创建日期对象 ---> 获得当前日期和时间 var now = new ...
- 欢迎访问我的快站fbengine.kuaizhan.com
欢迎访问我的快站 fbengine.kuaizhan.com
- 自动更新Chromium
Chromium 其实就是开发版本的Chrome, 即Chrome dev 版本.一般他的版本要比正式版的Chrome高两个及以上.比如正式版本现在是29,开发者版本已经是32了. 这表示很多新功能你 ...
- Python中的几种数据类型
大体上把Python中的数据类型分为如下几类: Number(数字) 包括int,long,float,complex String(字符串) 例如:hello,"hello" ...
- [我给Unity官方视频教程做中文字幕]beginner Graphics – Lessons系列之摄像机介绍Cameras
[我给Unity官方视频教程做中文字幕]beginner Graphics – Lessons系列之摄像机介绍Cameras 最近得到一些Unity官方视频教程,一看全是纯英文的讲解,没有任何字幕或者 ...
- Knockout JS实现任务管理应用程序
1.1.1 摘要 在博文<Ember.js实现单页面应用程序>中,我们介绍了使用Ember JS实现一个单页应用程序 (SPA),这使我想起了几年前写过一个任务管理程序,通过选择日期,然后 ...
- ios 截屏
把当前屏幕作为获取成为图片 - (UIImage *)rn_screenshot { UIGraphicsBeginImageContext(self.bounds.size); [sel ...
- Redis服务器的启动过程分析
转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/127.html?1455808771 本文将通过分析代码来介绍Redis的 ...
- Android开发学习之路-Android Design Support Library使用(CoordinatorLayout的使用)
效果图: 上面的这个图有两个效果是,一个是顶部的图片,在上滑之后会隐藏起来并且显示出一个ToolBar(ToolBar类似于ActionBar,但是只有ToolBar是兼容Material Desig ...
- lua如何构造类
function class(super, autoConstructSuper) local classType = {}; classType.autoConstructSuper = autoC ...