我有一个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);
}
}
在其CreateServiceInstanceListeners()
方法中,服务织物服务启动Web侦听器:
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
return new[]
{
new ServiceInstanceListener(serviceContext => new OwinCommunicationListener(Startup.ConfigureApp, serviceContext, "WebApiEndpoint"))
};
}
OwinCommunicationListener 是一个 Service Fabric 监听器,最终将启动 Web 服务器:
public Task<string> OpenAsync(CancellationToken cancellationToken)
{
// ...
WebApp.Start(this.listeningAddress, appBuilder => this.startup(appBuilder)));
return Task.FromResult(this.publishAddress);
}
我在处理一些请求时遇到了问题,我正在尝试通过请求头传递大量数据,但似乎由于请求头过长的限制而被拒绝,错误提示如下:
错误请求 - 请求头部太长 HTTP 错误 400。请求头部的大小太长。
有没有办法配置自托管的 Web API 来增加请求头的限制?