Closed pleb closed 13 years ago
A global filter is not executing when a controller contains a controller level filter.
Tried with ninject 2.3.0.6 and 2.2.1.1
To reproduce
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)] public class AlphaAttribute : Attribute {} public class FilterAlpha : IActionFilter { public void OnActionExecuting(ActionExecutingContext filterContext) {} public void OnActionExecuted(ActionExecutedContext filterContext) { filterContext.Controller.ViewData["alpha"] = "here"; } } public class FilterBeta : IActionFilter { public void OnActionExecuting(ActionExecutingContext filterContext) {} public void OnActionExecuted(ActionExecutedContext filterContext) { filterContext.Controller.ViewData["beta"] = "here"; } } [Alpha] public class WithController : Controller { public ActionResult Index() { return View(); } } public class WithoutController : Controller { public ActionResult Index() { return View(); } }
Registration
kernel.BindFilter<FilterAlpha>(FilterScope.Controller, 0) .WhenControllerHas<AlphaAttribute>(); kernel.BindFilter<FilterBeta>(FilterScope.Global, 0);
Views
<p>Alpha? @ViewData["alpha"]</p> <p>Beta? @ViewData["beta"]</p>
Example project can be found here
Replaced by https://github.com/ninject/ninject/issues/36
A global filter is not executing when a controller contains a controller level filter.
Tried with ninject 2.3.0.6 and 2.2.1.1
To reproduce
Registration
Views
Example project can be found here