diff --git a/src/Spring/Spring.Web.Mvc/SpringControllerFactory.cs b/src/Spring/Spring.Web.Mvc/SpringControllerFactory.cs index efaf6e7f..f36c2071 100644 --- a/src/Spring/Spring.Web.Mvc/SpringControllerFactory.cs +++ b/src/Spring/Spring.Web.Mvc/SpringControllerFactory.cs @@ -119,12 +119,13 @@ namespace Spring.Web.Mvc controller = (IController)controllers.Cast().First().Value; } } - else + + if (controller == null) { //pass to base class for remainder of handling if can't find it in the context controller = base.GetControllerInstance(requestContext, controllerType); } - + AddActionInvokerTo(controller); return controller; diff --git a/test/Spring/Spring.Web.Mvc.Tests/SpringControllerFactoryTests.cs b/test/Spring/Spring.Web.Mvc.Tests/SpringControllerFactoryTests.cs index 6fb30138..965f7565 100644 --- a/test/Spring/Spring.Web.Mvc.Tests/SpringControllerFactoryTests.cs +++ b/test/Spring/Spring.Web.Mvc.Tests/SpringControllerFactoryTests.cs @@ -85,7 +85,8 @@ namespace Spring.Web.Mvc.Tests [Test] public void CanRetrieveControllersNotRegisteredWithContainer() { - _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "NotInContainer"); + IController controller = _factory.CreateController(new RequestContext(new MockContext(), new RouteData()), "NotInContainer"); + Assert.IsInstanceOf(typeof(NotInContainerController), controller); } [Test]