C# 增加Web Api OWIN自身主机中的请求标头限制

C# 增加Web Api OWIN自身主机中的请求标头限制,c#,asp.net-web-api,owin,self-host-webapi,C#,Asp.net Web Api,Owin,Self Host Webapi,我有一个Web Api 2应用程序托管在Service Fabric中,它使用Microsoft.AspNet.WebApi.OwinSelfHost托管服务。我的创业课程非常典型: public static class Startup { public static void ConfigureApp(IAppBuilder app) { var config = new HttpConfiguration(); config.MapHttp

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

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

        config.MapHttpAttributeRoutes();
        // ...

        app.UseWebApi(config);
    }
}
服务farbric服务正在其
CreateServiceInstanceListeners()
方法中启动web侦听器:

protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
    return new[]
    {
        new ServiceInstanceListener(serviceContext => new OwinCommunicationListener(Startup.ConfigureApp, serviceContext, "WebApiEndpoint"))
    };
}
受保护的重写IEnumerable CreateServiceInstanceListeners()
{
返回新的[]
{
新ServiceInstanceListener(serviceContext=>新的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);
}
公共任务OpenAsync(CancellationToken CancellationToken) { // ... WebApp.Start(this.listengAddress,appBuilder=>this.startup(appBuilder)); 返回Task.FromResult(this.publishAddress); } 我遇到了一些请求的问题,我试图通过请求头传递大量数据。我似乎达到了极限,因为我的请求被拒绝,原因如下:

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


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

当然有办法增加自托管web api头的长度

但你真的想这么做吗?最有可能的结果是,您将使用更多的配置(其他web服务器、防火墙、负载平衡器、API客户端等)


一个不需要在请求头中发送大量数据的适当体系结构将使您的生活在未来变得更加轻松。

这是一个大型SAML令牌。在头中保留令牌的哈希值,并在正文中移动实际令牌如何?就我所知,请求正文的限制是相同的。把它移到尸体上不会改变任何事你确定吗?默认值为64兆。