IoC依赖注入自定义HTTP模块 - 怎么样? (ASP.NET) [英] IoC Dependency injection into Custom HTTP Module - how? (ASP.NET)

查看:123
本文介绍了IoC依赖注入自定义HTTP模块 - 怎么样? (ASP.NET)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义HTTP模块。我想使用IoC框架注入记录器,所以我可以在模块中记录错误。然而,当然我没有得到一个构造函数,所以不能注入它。这个最好的方法是什么?



如果您需要特定的IoC容器 - 我目前正在使用Windsor,但很快就会转到AutoFac。



谢谢

解决方案

我只是在我的博客上回答了这个问题



http://lozanotek.com/blog/archive/2009/08 /19/Autowire_IHttpModules_with_IoC.aspx


I have a custom HTTP Module. I would like to inject the logger using my IoC framework, so I can log errors in the module. However, of course I don't get a constructor, so can't inject it into that. What's the best way to go about this?

If you need the specific IoC container - I'm currently using Windsor, but may soon move to AutoFac.

Thanks

解决方案

I just answered this question on my blog.

See also http://lozanotek.com/blog/archive/2009/08/19/Autowire_IHttpModules_with_IoC.aspx

这篇关于IoC依赖注入自定义HTTP模块 - 怎么样? (ASP.NET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆