سؤال

I am creating a Nancy Module that will eventually be hosted inside of a Windows Service. I am currently running it inside of a WPF test application. To start the Nancy hosting, I am using Nancy.Hosting.Self and calling:

nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:8080"));
nancyHost.Start();

On my local machine I am able to go to a web browser and access my module by entering http://localhost:8080 into the address bar.

If I go to another machine I am not able to access the service. My Windows Firewall is turned off.

If I start the hosting with anything other than localhost in the baseUri, I get an "access denied" exception upon calling nancyHost.Start();

Is there something that I am missing? Should I be able to access the Nancy module from any machine as long as I know the IP:Port to the machine doing the hosting? Is there any type of "host headering" that I need to be aware of?

Thanks for your help with this.

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

المحلول

Windows will prevent you from listening on ports without permission. You can either run your process as administrator, or add permission using "netsh":

netsh http add urlacl url=http://+:8080/app user=domain\user

The "+" is a wildcard so it can listen on any IP.

Normally you'd handle the latter during installation, so you may want to run as admin to debug, then make sure your installer sets the relevant permissions.

نصائح أخرى

For local debugging, use

http://+:8733/Design_Time_Addresses

You can add any subdirectory you like, for example

http://+:8733/Design_Time_Addresses/myService 

and debug it at

http://localhost:8733/Design_Time_Addresses/myService

without running your IDE (Visual Studio?) as Administrator.

Look this: Self-Hosting-Nancy

The Host Configuration: UrlReservations, add under code:

var configuration = new HostConfiguration
        {
            UrlReservations = new UrlReservations { CreateAutomatically = true }
        };

OK, you can create your host!~

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