owin - 503 将 NancyFx 与 Owin 一起使用时出错

标签 owin nancy http-status-code-503

我正在尝试将 NancyFx 与 SignalR 结合使用。为了托管两者,我使用 Microsoft Owin。但不幸的是,当我尝试通过 PostMen(适用于 chromium 浏览器的 REST-Api 客户端扩展)访问 REST-API 时,我总是收到 503(服务不可用)。因此,我将主要成分提取到一个更简单的程序中,该程序允许我在 Nancy Selfhost 和 Owin 之间切换。 使用 Nancy SelfHost 时,一切正常,但使用 Owin 时仍然出现 503 错误。

internal class Program {
    private const bool _USE_SELF_HOST = false;

    private static void Main(string[] args) {
        if (_USE_SELF_HOST) {
            var host = "http://localhost:7084";
            UseSelfHost(host);
        } else {
            var host = "http://localhost:7084";
            UsingWebApp(host);
        }
    }

    private static void UseSelfHost(string host) {
        var webhost = new NancyHost(new Uri(host));
        webhost.Start();

        Console.ReadLine();
        webhost.Stop();
    }

    private static void UsingWebApp(string host) {
        var nancyHost = WebApp.Start<Startup>(host);
        Console.WriteLine($"Nancy started at {host}");
        Console.ReadLine();
        nancyHost.Dispose();
    }

}

public class MainModule : NancyModule {
    public MainModule() {
        Get["/"] = x => "Hello world!";
    }
}

我检查过:

  • netsh http show urlacl - 我可以打开此端口
  • Visual Studio 正在以管理员权限运行,但不需要这样做。

最佳答案

我的一位同事在我的 netsh 配置中发现了一个错误。我对同一个 tcp 端口有两个 urlacls:

Reservierte URL            : http://wks-user:7084/
    Benutzer: DOMAIN\user
        Abh▒ren: Yes
        Delegieren: No
        SDDL: D:(A;;GX;;;XXX)

Reservierte URL            : http://+:7084/
    Benutzer: DOMAIN\user
        Abh▒ren: Yes
        Delegieren: No
        SDDL: D:(A;;GX;;;XXX)

通过删除第一个条目后

netsh http delete urlacl http://wks-user:7084/

一切都按预期进行。

关于owin - 503 将 NancyFx 与 Owin 一起使用时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42970507/

相关文章:

南希- super 简单 View 引擎: Nested @Each

rest - 南希 : parsing "multipart/form-data" requests

java - HAProxy 之后 Wildfly 的 503 返回代码

asp.net-web-api - 在 ASP.NET Web API GrantResourceOwnerCredentials 中传回参数

asp.net-mvc - 使用 OWIN 将 ASP.NET MVC 应用程序连接到 Azure AD 或使用默认模板

asp.net - Autofac WebApi 2 OWIN 不工作

c# - 在没有 Razor View 引擎的情况下在南锡进行本地化

youtube - 从 youtube 数据 api v3 的 channel 列表中获取 topicDetails 时获取 503

python - 响应 503 python 请求

asp.net - 如何定义多个部分 Owin Startup 类并让它们全部运行其代码