题
我已经放弃了我正在使用的东西,去了最简单的代码:
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。该服务不可用。
我已经尝试了几种解决方案。包括几个变化: 远程访问Nancy Self主机
有什么想法吗?
解决方案
确保您以管理员身份运行Visual Studio,并且同时不使用此生成aceDicetagcode。看看自主托管演示,它为自主托管应用程序设置了几个不同的URIs https://github.com/nancyfx/nancy/blob/master/src/nancy.demo.hosting.self/program.cs#l12
其他提示
我不知道这个答案会有多少价值,但是当我开始使用这种设置组合时,我确实遇到了同样的503错误:
_nancyHost = new NancyHost(new HostConfiguration {
RewriteLocalhost = false
},
new Uri(string.Format("http://localhost:{0}", port)));
使用本地浏览器访问时遇到错误 http://localhost:3684/ 要在Windows服务中作为本地系统运行
先前的修订与 RewriteLocalHost
在true的默认设置一直在工作。这是我试图在这里诊断我的问题时尝试的事情之一: 如何远程访问自托管Nancy服务?
不隶属于 StackOverflow