Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is Castle Windsor trying to resolve my 'Content' and 'Scripts' folder as a controller?
    primarykey
    data
    text
    <p>I have created an ASP.NET MVC application and am trying to use Castle Windsor as my IOC</p> <p>However, when the controllers are trying to resolve I am getting 'Content' and 'Scripts' into the 'controllerName' parameter in the <code>CreateController(RequestContext requestContext, string controllerName)</code> method. Needless to say these are not controllers. They appears to be the folders of the web site</p> <p>Why is it trying to register these as controllers?</p> <p>How do I ignore these folders??</p> <p>thanks</p> <p>exception from WindsorControllerFactory</p> <p>Due to not being able to post the image I have to describe it - it basically just says </p> <blockquote> <p>'The contentcontroller was not found'</p> </blockquote> <p>Global.asax.cs</p> <pre><code>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=&gt;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)); } </code></pre> <p>windsorControllerFactory.cs</p> <pre><code>public IController CreateController(RequestContext requestContext, string controllerName) { try { controllerName = controllerName.ToLower() + "controller"; var controller = _container.Resolve&lt;IController&gt;(controllerName); return controller; } catch (ComponentNotFoundException) { throw new HttpException(404, string.Format("The {0} controller was not found", controllerName)); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload