I am trying to integrate nancy self hosting into my wpf project and when I start my program, I am able to connect to rest api from local browser, but cannot connect from another computer.
HostConfiguration hostConfigs = new HostConfiguration();
hostConfigs.UrlReservations.CreateAutomatically = true;
NancyHost host = new NancyHost(hostConfigs, new Uri("http://localhost:1234"));
host.Start();
Is there a way I can set Uri to wildcard, like in other built in web servers, 0.0.0.0 or + ?
EDIT Windows firewall is disabled!! I've also tried with different configurations of host, with http://10.10.10.149:1234 " as a host. I've tryed " http://+:1234 , this one doesn't build, it throws error.
I've also completely removed hostConfigs and added ACL to the system by running some commands in powershell, like suggested in many articles:
netsh http add urlacl url="http://+:12345/" user="Everyone"
Still, can only connect from local browser, not from another network location. Whenever I try to connect to machine where program is running via rest api, I get 503 Service Unavailable.
您需要将其更改为"http://+:1234"
以绑定到所有网络接口。
SOLUTION
Although my firewall is disabled completely, it was the firewall that was causing problems. I found solution in this article: C# HttpListener and Windows Firewall
All I needed to do, was adding the rule for system program to firewall. If anyone comes to this problem, this solution worked for me. I can now access api from another LAN too, so I guess it would work from any remote IP.
I have faced with a similar problem. I searched a lot of discussions and I had no answer. Then I found previous messages. I worked for me.
It was a firewall issue. And the solution;
1- Go to firewall settings 2- Inbound firewall rules 3- Add a new rule 4- Connection point (TCP / UDP) 5- TCP 6- (Enter port numbers) 7- Allow connection
I have shared my experience in case anyone need it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.