我的印象是,我可以將任何舊的可執行程序放在Apache的cgi-bin
目錄中,並將其用作CGI腳本。特別是,如果我有一個C#程序將CGI參數傳遞給Windows上的Apache中的可執行文件
static class TestProg
{
static void Main(string[] args)
{
Console.Write("Content-type: text/plain\r\n\r\n");
Console.WriteLine("Arguments:");
foreach (string arg in args)
Console.WriteLine(arg);
}
}
,然後去http://example.com/cgi-bin/TestProg?hello=kitty&goodbye=world
然後查詢字符串hello=kitty&goodbye=world
將作爲第一個參數,以主傳遞,所以我的頁面看起來應該像
Arguments:
hello=kitty&goodbye=world
不幸的是,我的查詢參數都沒有通過;該頁面加載並只打印Arguments:
而沒有任何跟隨它。
那麼如何讓我的查詢參數傳遞給這個程序呢?