I have created an ASP.NET MVC application and am trying to use Castle Windsor as my IOC
However, when the controllers are trying to resolve I am getting 'Content' and 'Scripts' into the 'controllerName' parameter in the CreateController(RequestContext requestContext, string controllerName)
method. Needless to say these are not controllers. They appears to be the folders of the web site
Why is it trying to register these as controllers?
How do I ignore these folders??
thanks
exception from WindsorControllerFactory
Due to not being able to post the image I have to describe it - it basically just says
'The contentcontroller was not found'
Global.asax.cs
public static IIocContainer Ioc;
protected void Application_Start()
{
InitialiseIocContainer();
RegisterViewEngine(ViewEngines.Engines);
RegisterRoutes(RouteTable.Routes);
StartProfiling();
}
private void InitialiseIocContainer()
{
IWindsorContainer _container = new WindsorContainer();
var controllerTypes = typeof (GidgetController).Assembly.GetTypes();
foreach (var controllerType in controllerTypes.Where((t=>typeof(IController).IsAssignableFrom(t))))
{
_container.AddComponentLifeStyle(controllerType.Name.ToLower(), controllerType, LifestyleType.Transient);
}
_container.AddComponent("a",typeof(IGidgetService), typeof(GidgetService));
_container.AddComponent("b",typeof(IGidgetRepository), typeof(GidgetRepository));
_container.AddComponent("c",typeof(IGidgetValidator), typeof(GidgetValidator));
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(_container));
}
windsorControllerFactory.cs
public IController CreateController(RequestContext requestContext, string controllerName)
{
try
{
controllerName = controllerName.ToLower() + "controller";
var controller = _container.Resolve<IController>(controllerName);
return controller;
}
catch (ComponentNotFoundException)
{
throw new HttpException(404, string.Format("The {0} controller was not found", controllerName));
}
}