C # CGI program,
1. Control Panel-> Programs and functions-> enable or disable Windows functions
Check related functions and click "OK"
2. Create a website and configure the Ising between ISAPI and CGI restrictions and processing programs.
3. CGI console application code:
Using System; using System. collections. generic; using System. text; using System. threading; namespace CGI {class Program {static int I = 0; static void Main (string [] args) {Thread thread = new Thread (new ParameterizedThreadStart (delegate (object obj) {while (true) {if (I <100) {I ++; Thread. sleep (100);} else {string queryStr = Environment. getEnvironmentVariable ("QUERY_STRING"); string [] paramArr = queryStr. split ('&'); string [] keyValue = paramArr [0]. split ('='); Console. write ("Content-Type: text/html; charset = GB2312; \ n"); Console. write ("{\" d \ ": \" your input parameter is: "+ keyValue [1] +", and the output result is: "+ I +" \ "}"); Environment. exit (0) ;}}}); thread. start ();} // end of Main} // end of Program}View Code
4. Web application Page code:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "CGITest. aspx. cs" Inherits = "Web Listener. CGITest" %> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">