C#HttpListener指定的网络名称格式无效 [英] C# HttpListener The format of the specified network name is not valid

查看:1513
本文介绍了C#HttpListener指定的网络名称格式无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一段很小的代码,尝试为 HttpListener 添加前缀:

I have this tiny piece of code where I try to add prefixes for my HttpListener:

listener = new HttpListener();
listener.Prefixes.Add("http://192.168.0.108:8088/");
listener.Start();

哪个抛出:


System.Net.HttpListenerException(0x80004005):指定的网络名称格式无效

System.Net.HttpListenerException (0x80004005): The format of the specified network name is not valid

一切:关闭防火墙,以管理员身份运行,使用 netsh http urlacl 注册给定的URL,但到目前为止,没有任何效果。

I've tried everything: turning off firewall, running as administrator, registering given URL with netsh http urlacl and yet, nothing has worked so far.

我用 netstat 检查了该地址是否可以使用。
奇怪的是,我一直使用此地址很长时间,直到 Windows 10 Fall Creators Update ,自此更新以来,只有 localhost 正在工作。

I checked with netstat if that address is open to use and it is. The weird thing about this is that I have been using this address for a long time until Windows 10 Fall Creators Update, since this update, only localhost is working.

还有其他我忘记或可以尝试的东西吗?

Is there anything else that I forgot about or might try?

推荐答案

您可能忘记了将系统配置为侦听来自指定IP地址的 HTTP 协议通信。尝试运行以下命令以包含它:

You probably forgot to configure your system to listen for HTTP protocol communication coming from the specified IP address. Try running the following command to include it:

netsh http add iplisten 192.168.0.108

完成后,检查地址列表(现在应该显示IP):

Once this is done, check the list of the addresses (in which your IP should now appear):

netsh http show iplisten

然后尝试再次运行代码。

and then try to run your code again.

这篇关于C#HttpListener指定的网络名称格式无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆