ninject/Ninject.Web.Mvc

Filters not firing for MVC Area

dmeagor opened this issue · 1 comments

Hi

Been working on this for two days now without luck. Does anyone know why the filters (in this case the UnitOfWorkFilter) are not firing for the controllers within an MVC Area. Everything else seems to be working ok.

Binding in: public override void Load()

Kernel.BindFilter<UnitOfWorkFilter>(FilterScope.Action, 0);

Ninject is starting using PreApplicationStartMethod rather than extending HttpApplication. Could this be the cause?

[assembly: WebActivator.PreApplicationStartMethod(typeof(NinjectWebCommon), "Start")]
[assembly: WebActivator.ApplicationShutdownMethod(typeof(NinjectWebCommon), "Stop")]

namespace FreeSurvey.Web.Mvc
{
    public static class NinjectWebCommon
    {
        private static readonly Bootstrapper Bootstrapper = new Bootstrapper();

        /// <summary>
        /// Starts the application
        /// </summary>
        public static void Start()
        {
            DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
            DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));

            Bootstrapper.Initialize(CreateKernel);

            GlobalConfiguration.Configuration.DependencyResolver = new NinjectResolver(Bootstrapper.Kernel);
            GlobalHost.DependencyResolver = new SignalRNinjectResolver(Bootstrapper.Kernel);
            ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactory(Bootstrapper.Kernel));
        }

Please disregard. I got to the bottom of the issue.