我有一个托管在 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 以增加请求标头的限制?