4

我有一个托管在 Service Fabric 中的 Web Api 2 应用程序,它使用 Microsoft.AspNet.WebApi.OwinSelfHost 来托管服务。我的 Startup 课程非常典型:

public static class Startup
{
    public static void ConfigureApp(IAppBuilder app)
    {
        var config = new HttpConfiguration();

        config.MapHttpAttributeRoutes();
        // ...

        app.UseWebApi(config);
    }
}

service farbric 服务正在其CreateServiceInstanceListeners()方法中启动 Web 侦听器:

protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
    return new[]
    {
        new ServiceInstanceListener(serviceContext => new OwinCommunicationListener(Startup.ConfigureApp, serviceContext, "WebApiEndpoint"))
    };
}

OwinCommunicationListener 是一个服务结构监听器,它最终将启动 Web 服务器:

public Task<string> OpenAsync(CancellationToken cancellationToken)
{
    // ...
    WebApp.Start(this.listeningAddress, appBuilder => this.startup(appBuilder)));

    return Task.FromResult(this.publishAddress);
}

我遇到了一些请求的问题,我试图通过请求标头传递大量数据。我似乎达到了极限,因为我的请求被以下内容拒绝:

错误请求 - 请求太长 HTTP 错误 400。请求标头的大小太长。

有没有办法配置自托管 Web api 以增加请求标头的限制?

4

1 回答 1

1

当然,必须有办法增加自托管 Web API 标头长度。

但是你真的想做吗?很可能你最终会使用更多的配置(其他 Web 服务器、防火墙、负载平衡器、API 客户端等)

不涉及在请求标头中发送大量数据的适当架构将使您的生活在未来变得更加轻松。

于 2017-08-24T13:28:10.560 回答