How do I remotely access self-hosted Nancy service?

后端 未结 2 1320
刺人心
刺人心 2021-01-14 12:50

I am creating a simple Windows service that hosts a Nancy instance to provide views of its internal data. Everything works as expected when using a browser on the local mach

2条回答
  •  感情败类
    2021-01-14 13:05

    Use the HostConfiguration and let Nancy make the URL reservations automaticaly for you.

    var config = new HostConfiguration
    {
        RewriteLocalhost = true,
        UrlReservations = new UrlReservations { CreateAutomatically = true }
    };
    host = new NancyHost(new Uri("http://localhost:8080"), new DefaultNancyBootstrapper(), config);
    host.Start();
    

    Note that this will force ACL to create network rules for new ports if they do not already exist.

提交回复
热议问题