WinForms FAQ - CGI

Find answers for the most frequently asked questions
Expand All Collapse All

You sure can. Here is a simple CGI program that prints out the current time and also all the environment variables that are available to it.


using System;

public class cgi
{
	public static void Main(string[] args)
	{
		Console.WriteLine('Content-Type:text/html\n\n');
		
		if(args.GetLength(0) == 0)
			Console.WriteLine('The time now is {0}', System.DateTime.Now.ToString());
		else
			Console.WriteLine('Hi {0}, the time now is {1}', args[0], System.DateTime.Now.ToString());
	
		foreach(string s in Environment.GetEnvironmentVariables().Keys)
			Console.WriteLine('
{0} : {1}
',s, Environment.GetEnvironmentVariables()[s]);
	}
}
Permalink

Share with

Couldn't find the FAQs you're looking for?

Please submit your question and answer.