Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

.net - C# HttpListener The format of the specified network name is not valid

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();

Which throws:

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

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...