日期:2014-05-18  浏览次数:20700 次

【求助】C#写CGI的问题!
我在网上找到下面这段代码!(http://pc.sheup.com/pc/pc2448.htm):
class zzz
{
public static void Main()
{
System.Console.WriteLine("Content-Type:text/html\n");
System.Console.WriteLine("< body bgcolor=blue >");
System.Console.WriteLine("< center >< p >< p >");
System.Console.WriteLine("< b >Hello to everyone.Its me SunWen< b >");
System.Console.WriteLine("< /body >");
}
}
把该代码编译成a.exe文件,站点的权限定为“脚本和可执行文件”,就可以用http://localhost/a.exe得到一个页面。
但是我写出来了就不行,得到错误信息如下:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

未处理的异常: System.ArgumentException: URL 上的无效目录。

这是怎么回事呢?望各位大侠不吝赐教!!!


------解决方案--------------------
“http://localhost/a.exe” “无效目录”
很明显的提示啊!

这个路径明显有问题嘛!localhost表示本地机器,那你a.exe即没有在虚拟目录,也没有给出文件系统路径,你让它显示什么呢?

Internet信息服务--本地计算机--网站--默认网站--右键新建一个虚拟目录test,那么你的目录默认是保存在C:\Inetpub\wwwroot下,将你的a.exe放到该目录下,你便可以通过以下方式访问a.exe了:
http://localhost/test/a.exe