This project is read-only.


Topics: Web Api
Nov 1, 2011 at 4:35 PM

I don't see HttpHostConfiguration class as part of Microsoft.ApplicationServer.HttpEnhancements dll. Any reason why i am missing this.

Nov 1, 2011 at 4:43 PM

The new configuration class in Preview 5 is HttpConfiguration. There is also an “enhanced” version in the Web API enhancements called WebApiConfiguration.

Daniel Roth

Nov 1, 2011 at 5:10 PM


I have a custom message handler for doing api key verification. I am using CastleWindsor as my IOC container. I am registering my types in castle Windsor.  Below is my constructor code . It is telling me that HttpMessageHandler is not registered. How i can resolve this. urgent help is appreciated.

public ApiVerificationHandler(HttpMessageHandler innerHandler, IVideoRepository repository) :base(innerHandler){             _repository = repository;         }

configuration.MessageHandlerFactory = (() => new DelegatingHandler[] {(DelegatingHandler) container.Resolve(typeofApiVerificationHandler))}); 

Thanks in advance.
Nov 1, 2011 at 5:44 PM

How are you registering the configuration object? Are you using MapServiceRoute? Are you in IIS/ASP.NET or self-host?

Nov 1, 2011 at 7:11 PM

Yes I am using the MapServiceRoot metthod. i am using MVC as the host process. and using the below line to set configuration to all the routes.

Nov 1, 2011 at 9:08 PM

Is the error you are getting from Castle Windsor i.e. Windsor is telling you the handler is not registered?


Nov 2, 2011 at 10:35 AM

Yes i am getting the error from castle Windsor

Below is the error info.

Can't create component 'Castle.WCF.WebApi.Handlers.ApiVerificationHandler' as it has dependencies to be satisfied.

Castle.WCF.WebApi.Handlers.ApiVerificationHandler is waiting for the following dependencies:

- System.Net.Http.HttpMessageHandler which was not registered.

Code block

var configuration = new WebApiConfiguration();
  var container = InitializeContainer();

  configuration.MessageHandlerFactory = (() => new DelegatingHandler[] {(DelegatingHandler) container.Resolve(typeofApiVerificationHandler))});
 configuration.CreateInstance = ((type, requestMessage, o) => container.Resolve(type));

 private IWindsorContainer InitializeContainer()
            container = new WindsorContainer();
            return container;
Nov 3, 2011 at 9:01 AM

Your ApiVerificationHandler cannot be resolved by windsor becuase HttpMessageHandler has not been registered into the container and neither you can register it...

Keep in mind in prev 5 MessageHandler does no longer required HttpMessageHandler in the constructor.

I assume if you update your ApiVerificationHandler to

public ApiVerificationHandler( IVideoRepository repository){...}

windsor will resolve it: it works with no problem for me

Nov 3, 2011 at 9:12 AM

doh, great catch!

Yes, in the past we required the message handler to get passed in as a param. We heard a lot of feedback that it made constructing handlers with an IoC either impossible or very hard depending on the container :-)

So in Preview 5, we removed the requirement for passing in that constructor dependnecy and made it be a property on the handler which our infrastructure automatically sets for you. That means you no longer have to worry about it.

So as crixo72 said....get rid of the handler on the ctor and you should be golden.

Nov 4, 2011 at 5:55 PM

Thanks guys,

It solved the problem