Adding controller-as-filter support
If the controller implements IFilter, it will be added to the filters collection. It's hardcoded to be 'first' as it was in MVC.
This commit is contained in:
parent
67b33868a3
commit
ae4e3bc61d
|
|
@ -88,6 +88,14 @@ namespace Microsoft.AspNet.Mvc.Filters
|
|||
|
||||
ApplyFilterToContainer(filterItem.Filter, filterFactory);
|
||||
}
|
||||
|
||||
var controllerFilter = context.ActionContext.Controller as IFilter;
|
||||
if (controllerFilter != null)
|
||||
{
|
||||
// If the controller implements a filter, we want it to be the first to run.
|
||||
var descriptor = new FilterDescriptor(controllerFilter, FilterScope.Action);
|
||||
context.Result.Insert(0, new FilterItem(descriptor, controllerFilter));
|
||||
}
|
||||
}
|
||||
|
||||
private void InsertControllerAsFilter(FilterProviderContext context, IFilter controllerFilter)
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@
|
|||
<Compile Include="Filters\ResultExecutionDelegate.cs" />
|
||||
<Compile Include="Filters\ResultFilterAttribute.cs" />
|
||||
<Compile Include="Filters\ServiceFilterAttribute.cs" />
|
||||
<Compile Include="ControllerFilterProvider.cs" />
|
||||
<Compile Include="FormContext.cs" />
|
||||
<Compile Include="HttpDeleteAttribute.cs" />
|
||||
<Compile Include="HttpGetAttribute.cs" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue