bra*_*ost 3 dependency-injection castle-windsor self-hosting asp.net-mvc-4 asp.net-web-api
我有一个MVC4 webapi控制器.它没有无参数构造函数.所以,我使用Windsor依赖解析器,在System.Web.Http.WebHost下工作时一切正常.但是,当我尝试使用HttpSelfHostServer时,我收到异常消息:
Looks like you forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule
To fix this add
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
to the <httpModules> section on your web.config.
If you plan running on IIS in Integrated Pipeline mode, you also need to add the module to the <modules> section under <system.webServer>.
Alternatively make sure you have Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 assembly in your GAC (it is installed by ASP.NET MVC3 or WebMatrix) and Windsor will be able to register the module automatically without having to add anything to the config file.
显然,windsor di无法注册他的HttpModule.我试过补充一下
<system.web>
<httpModules>
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
</httpModules>
</system.web>
在我的app.config中,没有运气.试过WebActivator使用PreApplicationStart方法也没有运气.有没有办法为自托管的webapi应用程序添加httpModule?
自托管时无法使用HttpModules.它们是ASP.NET特有的功能.
| 归档时间: |
|
| 查看次数: |
1352 次 |
| 最近记录: |