Asp.net Mvc中MVCContrib中无法使用Castle的发解决方案 - 乱世重典

时间:2008-04-01 22:28:04   来源:   作者:

在使用Asp.net Mvc MVCContrib 0.0.1.91中的Castle时会出现No component for key Home was found这样的错误 来源中国教程网

错误解决方法如下:

http://www.cnjiaocheng.com

下载MvcContrib源代码,更改MvcContrib.Castle的WindsorControllerFactory.cs中的34行CreateController方法为:

来源中国教程网

  http://www.cnjiaocheng.com

            public IController CreateController(RequestContext context, string controllerName)
            {
                        controllerName = controllerName +
"Controller"; //更改了这里

                    IWindsorContainer container = GetContainer(context); http://www.cnjiaocheng.com
                   
return (IController)container.Resolve(controllerName);
            }