Note that there are some explanatory texts on larger screens.

plurals
  1. POCastle Windsor with MVC 2.0 and Areas
    primarykey
    data
    text
    <p>Wanted to ask a quick question regarding castle windsor and implementing IoC for Controllers in Areas. Does Castle 2.5 support MVC 2.0 areas?</p> <p>My Castle config works ok for my root controller in the root of my site but any area controllers are not found with a </p> <p>The IControllerFactory 'XXX.Castle.WindsorControllerFactory' did not return a controller for the name 'Registration'.</p> <p>I am using Castle directly not through MvcContrib</p> <p>Code as follows:</p> <pre><code>class WindsorControllerFactory : DefaultControllerFactory { WindsorContainer container; // The constructor: // 1. Sets up a new IoC container // 2. Registers all components specified in web.config // 3. Registers all controller types as components public WindsorControllerFactory() { // Instantiate a container, taking configuration from web.config container = new WindsorContainer(); // Also register all the controller types as transient var controllerTypes = from t in Assembly.GetExecutingAssembly().GetTypes() where typeof(IController).IsAssignableFrom(t) select t; foreach (Type t in controllerTypes) { //container.AddComponentLifeStyle(t.FullName, t, LifestyleType.Transient); container.Register(Component.For(t).Named(t.FullName).LifeStyle.Transient); } container.Install(new WindsorInstaller()); } protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { if (controllerType != null) { return (IController)container.Resolve(controllerType); } return null;// base.GetControllerInstance(requestContext, controllerType); } } </code></pre> <p>Many thanks</p> <p>Richard</p>
    singulars
    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.
    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