Tag: hyprlinkr

ASP Web Api – IoC – 解析HttpRequestMessage

我正在尝试使用ASP.NET WebAPI设置Castle Windsor。 我也在使用Hyprlinkr包( https://github.com/ploeh/Hyprlinkr ),因此需要将HttpRequestMessage的实例注入到我的控制器的一个依赖项中。 我正在关注Mark Seemann的这篇文章 – http://blog.ploeh.dk/2012/04/19/WiringHttpControllerContextWithCastleWindsor.aspx ,但我发现尽管API运行,但当我调用它时,请求只是挂起。 没有错误消息。 就像它处于一个无限循环中一样。 它停留在我的Custom ControllerActivator调用Resolve上 我想我的一些城堡注册错了。 如果我删除上面文章中提到的那些,那么我可以成功调用API(虽然没有我需要解决的依赖项) 有任何想法吗? 代码如下 //Global.asax public class WebApiApplication : HttpApplication { private readonly IWindsorContainer container; public WebApiApplication() { container = new WindsorContainer( new DefaultKernel( new InlineDependenciesPropagatingDependencyResolver(), new DefaultProxyFactory()), new DefaultComponentInstaller()); container.Install(new DependencyInstaller()); } protected void Application_Start() { GlobalConfiguration.Configuration.Services.Replace(typeof(IHttpControllerActivator), new WindsorCompositionRoot(this.container)); […]