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]);
}
}
Share with