views:

156

answers:

0

Hello, Try to ASP.NET MVC 2 Areas and have a problem. I have a User Area and a Blog area. User area is working properly but when I use my Blog area the controllerType is null in my GetControllerInstance. I have not made any changes in my areas so everything is as it was when I created them. I Have also tried to add a test area with name "test" but it does not work either. It's just my User area that works. Has debug my routes and everything is as it should.

For dependency injection I use Unity:

public class UnityControllerFactory : DefaultControllerFactory { IUnityContainer container;

public UnityControllerFactory(IUnityContainer container) {
    this.container = container;
}

protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) {
    if (controllerType == null) {
        throw new ArgumentNullException("controllerType");
    }
    if (!typeof(IController).IsAssignableFrom(controllerType)) {
        throw new ArgumentException("Type requested is not a controller", "controllerType");
    }

    return container.Resolve(controllerType) as IController;
} 

}

What can be wrong? Why is the controllerType null in all the areas except User? Thanks