相关疑难解决方法(0)

看起来你忘了在Windsor Castle和IIS7上注册http模块

我在我的一个MVC项目中使用windsor DI框架.当我尝试从Visual Studio 2008运行时,该项目工作正常.

但是,当我尝试在IIS7中运行创建应用程序的项目时,我收到以下错误消息:

看起来您忘记注册http模块Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule将"<add name ="PerRequestLifestyle"type ="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule,Castle.MicroKernel"/>'添加到您网站上的部分.配置

但是这个模块已经存在于web.config文件的httpmodule部分中.

有谁知道我必须做些什么来消除这个问题.

asp.net-mvc iis-7 castle-windsor

26
推荐指数
2
解决办法
1万
查看次数

城堡PerRequestLifestyle无法识别

Castle/Windsor新手,请耐心等待.

我目前正在使用框架System.Web.Mvc.Extensibility,并在其启动代码中,它注册了HttpContextBase,如下所示:

container.Register(Component.For<HttpContextBase>().LifeStyle.Transient.UsingFactoryMethod(() => new HttpContextWrapper(HttpContext.Current)));
Run Code Online (Sandbox Code Playgroud)

我想要做的是改变行为并将httpContextBase的生活方式改为PerWebRequest.

所以我将代码更改为以下内容:

container.Register(Component.For<HttpContextBase>().LifeStyle.PerWebRequest.UsingFactoryMethod(() => new HttpContextWrapper(HttpContext.Current)));
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时,我收到以下错误:

 System.Configuration.ConfigurationErrorsException: Looks like you forgot to 
 register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule
 Add '<add name="PerRequestLifestyle" 
 type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.MicroKernel" 
 />' to the <httpModules> section on your web.config
Run Code Online (Sandbox Code Playgroud)

这是我做下<system.web>和<system.webServer>,但是,我仍然得到同样的错误.任何提示?

提前致谢.

更新

每个请求添加了代码块

在system.web.mvc.extensibility框架中,有一个名为extendedMvc​​Application的类,它继承自HttpApplication,在Application_start方法中,它调用BootStrapper.Execute().此方法的实现如下:

public void Execute()
    {
        bool shouldSkip = false;

        foreach (IBootstrapperTask task in ServiceLocator.GetAllInstances<IBootstrapperTask>().OrderBy(task => task.Order))
        {
            if (shouldSkip)
            {
                shouldSkip = false;
                continue;
            }

            TaskContinuation continuation = task.Execute(ServiceLocator);

            if (continuation == TaskContinuation.Break) …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc castle-windsor perwebrequest

5
推荐指数
1
解决办法
4316
查看次数