Nancy Self Hosting - 服务不可用 - Win7

时间:2012-10-01 18:12:56

标签: .net nancy

我已经废弃了我正在使用的内容并转到了最简单的代码:

class Program
{
    static void Main(string[] args)
    {
        var nancyHost = new Nancy.Hosting.Self.NancyHost(new   Uri("http://localhost:8080"));
        nancyHost.Start();

        Console.ReadLine();
        nancyHost.Stop();
    }
}
public class MainModule : Nancy.NancyModule
{
    public MainModule()
    {
        Get["/"] = x =>
        {
            return "Hello world!";
        };
    }
}

当我浏览

   http://localhost:8080

我明白了:


服务不可用

HTTP错误503.该服务不可用。


我尝试了几种解决方案。包括以下几种变体:Remote access to a Nancy Self Host

有什么想法吗?

2 个答案:

答案 0 :(得分:5)

确保以管理员身份运行Visual Studio,并且8080不会被其他内容同时使用。看看自托管演示,它为自托管应用程序设置了几个不同的URI https://github.com/NancyFx/Nancy/blob/master/src/Nancy.Demo.Hosting.Self/Program.cs#L12

答案 1 :(得分:0)

我不知道这个答案会有多大价值,但是当我使用这种设置组合开始Nancy时,我确实遇到了同样的503错误:

_nancyHost = new NancyHost(new HostConfiguration { 
        RewriteLocalhost = false
    }, 
    new Uri(string.Format("http://localhost:{0}", port)));

使用本地浏览器访问作为本地系统的Windows服务中运行的Nancy http://localhost:3684/时遇到错误

默认设置为true的RewriteLocalHost的先前修订版已经有效。这是我在尝试诊断问题时尝试的其中一项:How do I remotely access self-hosted Nancy service?