我正在设计一个使用.NET的http服务器。 我基本上使用HttpListener从客户端获取http请求。 在开始时,我必须指定URL并将该URL添加到HttpListener。 然后,我必须让HttpListener开始收听。 开始收听时会出现问题。它开始聆听时会产生异常。为什么HttpListener无法启动?
代码如下:
string url =“http:// *:80 /”; //其中*是我的PC的IP地址。
listener = new HttpListener();
listener.Prefixes.Add(url);
listener.Start(); //this is where exception occurs, it couldn't start!!!
我的猜测是我必须使用netsh注册该URL。这是对的吗?
这个例外是什么意思?你还有其他什么东西在80端口上运行? –