我已经废弃了我正在使用的内容并转到了最简单的代码:
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
有任何想法吗?
解决方法
确保以管理员身份运行Visual Studio,并且8080不会被其他内容同时使用.看看自托管演示,它为自托管应用程序
https://github.com/NancyFx/Nancy/blob/master/src/Nancy.Demo.Hosting.Self/Program.cs#L12设置了几个不同的URI