【发布时间】:2013-11-12 09:07:56
【问题描述】:
我正在使用 .NET 设计一个 http 服务器。 我基本上使用 HttpListener 从客户端获取 http 请求。 一开始,我必须指定 URL,然后将该 URL 添加到 HttpListener。 然后,我必须让 HttpListener 开始监听。 当它开始收听时,就会出现问题。当它开始监听时会产生一个异常。
代码如下:
字符串 url = "http://*:80/"; //其中 * 是我的 PC 的 IP 地址。
监听器 = 新的 HttpListener();
listener.Prefixes.Add(url);
listener.Start(); //this is where exception occurs, it couldn't start!!!
我的猜测是我必须使用 netsh 注册该 URL。这是正确的吗?
【问题讨论】:
-
异常说明了什么?你在 80 端口上还有其他东西在运行吗?