【问题标题】:Cannot access NancyHost server from another computer/mobile in same network无法从同一网络中的另一台计算机/移动设备访问 NancyHost 服务器
【发布时间】:2019-12-28 14:50:28
【问题描述】:

这是我的代码:

static void Main(string[] args)
        {
            string url = "http://localhost:3000";
            HostConfiguration hostConfigs = new HostConfiguration()
            {
                RewriteLocalhost = true,
                UrlReservations = new UrlReservations() { CreateAutomatically = true }
            };
            NancyHost nancyHost = new NancyHost(new Uri(url), new DefaultNancyBootstrapper(), hostConfigs);
            nancyHost.Start();
            Console.WriteLine("Web server running: " + url);

            Console.ReadLine();
            try
            {
                nancyHost.Stop();
            } catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("Web server stopped: " + url);
            Console.ReadLine();

        }

运行我的程序后,它通过自动执行netsh http add urlacl url=http://+:3000/ user=everyone这个命令来请求在Reserved URL中添加http://+:3000/的管理权限。

但是,在接受管理权限后,虽然它在Reserved URL 中添加了http://+:3000/,但我无法从我的手机/另一台与我的路由器连接到同一网络的计算机访问我的网络服务器。

失败太多后,我也手动添加了这些Reserved URL
netsh http add urlacl url=http://localhost:3000/ user=everyone
netsh http add urlacl url=http://127.0.0.1:3000/ user=everyone
netsh http add urlacl url=http://192.168.0.161:3000/ user=everyone192.168.0.161 -->我的主机IP地址

但是,它没有用。

【问题讨论】:

    标签: webserver nancy


    【解决方案1】:

    这是我犯的一个愚蠢的错误。
    我刚刚关闭了我的公共防火墙,它可以工作了!!

    【讨论】:

      猜你喜欢
      • 2020-08-24
      • 2023-03-21
      • 2020-07-06
      • 1970-01-01
      • 2023-03-20
      • 2011-03-30
      • 2019-10-05
      • 1970-01-01
      • 2020-12-16
      相关资源
      最近更新 更多