سؤال

Very new to the Self Host WebApi, but I am very impressed with its ease of use and extendability. At least through this tutorial. Everything I've done so far works on my development machine whether I use localhost, 127.0.0.1, or my LAN Ip (192.168.0.x) but I am baffled why I can't access the service from any other computer even others in the same subnet.

In short after going through the tutorial on the machine where it is running: Browsing to

localhost:3636/api/products/ 

results in the expected xml return. On another machine on the LAN browsing to:

192.168.0.x:3636/api/products/ 

results in a timeout Data points for those who might know how this all interacts:

1.) My dev machine(192.168.0.x, server, host whatever you want to call it) has IIS on it; I was so paranoid it was in the way that I stopped it via the Administration GUI

2.) I have reserved the URL/Port with the following command line executions:

    >netsh http add urlacl url=http://+:3636/ user=DOMAIN\USER listen=yes delegate=yes
    >netsh http add urlacl url=http://192.168.0.x:3636/ user=DOMAIN\USER listen=yes delegate=yes

2.b) I've tried both of those together and individually, and tried changing the user to "everyone" to no avail

3.) I have tried to change the code in the tutorial to set the

    config.HostNameComparisonMode = HostNameComparisonMode.Exact //default is Strong Wildcard 

4.) I can successfully ping and tracert to 192.168.0.x from other machines on the LAN

5.) A friend recommended I setup a TCPListener and ensure I could telnet to that to eliminate the firewall as a possibility. If that logic is sound, the firewall isn't the problem

EDIT: Thanks for your help, here's another data point that I believe confirms it's not a firewall issue. I previously posted this connection when behind a rather obtuse (at least to a non Certified guy like me) Juniper Firewall/Router. I have since redone the tutorial on another machine (without IIS) on my home network and still cannot publish the service to other computers within my LAN. Any ideas?

هل كانت مفيدة؟

المحلول

Well it wasn't the hardware firewall, it was the windows firewall! yikes i wasted a bunch of time on that. Once I turned off the windows firewall (the code runs in an intranet anyway) everything worked.

Anyone know of a good site that explains how firewalls and wireshark interact; or i suppose that just has to be one's first test.

نصائح أخرى

I would try a couple things:

First off, get rid of the HostNameComparisonMode line. That might actually disable requests coming from other machines.

If things still don't work, try getting rid of the URL ACLs and run your application as an administrator and see if that works. If that works, you may be able to add the URL ACL back on and not have to run as an administrator. You should only need the one with '+' as the hostname.

I faced the same problem when i tried to self host using OWIN. What worked for me was -

  1. Run Visual Studio as an Admin
  2. Remove any and all netsh urlacl port registrations that I had added while debugging this issue
  3. Add a inbound rule to my windows firewall I followed the instructions on this link https://docs.microsoft.com/en-us/dotnet/framework/wcf/samples/firewall-instructions Check out the section - To enable a port range in advance

That's it! I was able to call my api from other computers on the network.

Hope this helps...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top