How to resolve display handler issues for WebAPI + OData + Owin + Ninject

I posted it yesterday ...

https://stackoverflow.com/questions/32615769/owin-webapi-odata-v4-aspnet-identity-initialisation

If I changed the first line of the launch configuration method to ...

var config = GlobalConfiguration.Configuration ?? new HttpConfiguration();

Then I get this error when navigating to the root ...

The 'DelegatingHandler' list is not valid because the 'InnerHandler' 'CorsMessageHandler' property is not zero. Parameter Name: Handlers

I found some information stating that the base implementation of "HttpServer" had a batch download error in it, and that Microsoft stated that they had introduced a new batch processing platform, so we won’t fix it, the blogs offered by this sample code to fix the error ...

public class BatchServer : HttpServer
{
    private readonly HttpConfiguration _config;

    public BatchServer(HttpConfiguration configuration)
        : base(configuration)
    {
        _config = configuration;
    }

    protected override void Initialize()
    {
        var firstInPipeline = _config.MessageHandlers.FirstOrDefault();
        if (firstInPipeline != null && firstInPipeline.InnerHandler != null)
        {
            InnerHandler = firstInPipeline;
        }
        else
        {
            base.Initialize();
        }
    }
}

-, , , .

, , , .

+4
1

​​ . , , , , , .UseWebApi(), HttpServer.

, Startup.cs :

HttpConfiguration config = GlobalConfiguration.Configuration ?? new HttpConfiguration();
config.EnableCors();
//the next two lines I had to change - instead of 'config' pass in the HttpServer
appBuilder.UseWebApi(GlobalConfiguration.DefaultServer);
appBuilder.UseNinjectWebApi(GlobalConfiguration.DefaultServer);
+4

Source: https://habr.com/ru/post/1607798/


All Articles