diff --git a/samples/MvcSample.Web/Filters/UserNameProvider.cs b/samples/MvcSample.Web/Filters/UserNameProvider.cs
index 918ff6987c..00d94fada4 100644
--- a/samples/MvcSample.Web/Filters/UserNameProvider.cs
+++ b/samples/MvcSample.Web/Filters/UserNameProvider.cs
@@ -2,12 +2,12 @@
namespace MvcSample.Web.Filters
{
- public class UserNameProvider : ActionFilterAttribute
+ public class UserNameProvider : IActionFilter
{
private static readonly string[] _userNames = new[] { "Jon", "David", "Goliath" };
private static int _index;
- public override void OnActionExecuting(ActionExecutingContext context)
+ public void OnActionExecuting(ActionExecutingContext context)
{
object originalUserName = null;
@@ -20,5 +20,9 @@ namespace MvcSample.Web.Filters
context.ActionArguments["userName"] = _userNames[(_index++)%3];
}
}
+
+ public void OnActionExecuted(ActionExecutedContext context)
+ {
+ }
}
}
diff --git a/samples/MvcSample.Web/FiltersController.cs b/samples/MvcSample.Web/FiltersController.cs
index c40b06b3ff..45b2efadcc 100644
--- a/samples/MvcSample.Web/FiltersController.cs
+++ b/samples/MvcSample.Web/FiltersController.cs
@@ -11,7 +11,7 @@ namespace MvcSample.Web
[PassThrough(Order = 2)]
[InspectResultPage]
[BlockAnonymous]
- [UserNameProvider(Order = -1)]
+ [TypeFilter(typeof(UserNameProvider), Order = -1)]
public class FiltersController : Controller
{
public User User { get; set; }
diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/DefaultFilterProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/DefaultFilterProvider.cs
index 3d40658dbd..e63eb41fab 100644
--- a/src/Microsoft.AspNet.Mvc.Core/Filters/DefaultFilterProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/Filters/DefaultFilterProvider.cs
@@ -73,7 +73,10 @@ namespace Microsoft.AspNet.Mvc.Filters
throw new InvalidOperationException("Type filter must implement IFilter");
}
- var typeFilter = _typeActivator.CreateInstance(ServiceProvider, typeFilterSignature.ImplementationType) as IFilter;
+ var typeFilter = (IFilter)_typeActivator.CreateInstance(
+ ServiceProvider,
+ typeFilterSignature.ImplementationType,
+ typeFilterSignature.Arguments);
ApplyFilterToContainer(typeFilter, filter);
filterItem.Filter = typeFilter;
diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/ITypeFilter.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/ITypeFilter.cs
index 08f1d4b7a2..eccb2ed6df 100644
--- a/src/Microsoft.AspNet.Mvc.Core/Filters/ITypeFilter.cs
+++ b/src/Microsoft.AspNet.Mvc.Core/Filters/ITypeFilter.cs
@@ -4,6 +4,8 @@ namespace Microsoft.AspNet.Mvc
{
public interface ITypeFilter : IFilter
{
+ object[] Arguments { get; }
+
Type ImplementationType { get; }
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Core/Filters/TypeFilterAttribute.cs b/src/Microsoft.AspNet.Mvc.Core/Filters/TypeFilterAttribute.cs
new file mode 100644
index 0000000000..a7fc9bc12d
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.Core/Filters/TypeFilterAttribute.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Diagnostics;
+
+namespace Microsoft.AspNet.Mvc
+{
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
+ [DebuggerDisplay("TypeFilter: Type={ImplementationType} Order={Order}")]
+ public class TypeFilterAttribute : Attribute, ITypeFilter, IOrderedFilter
+ {
+ public TypeFilterAttribute(Type type)
+ {
+ ImplementationType = type;
+ }
+
+ public object[] Arguments { get; set; }
+
+ public Type ImplementationType { get; private set; }
+
+ public int Order { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj b/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj
index 776463d6f8..7390e2a347 100644
--- a/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj
+++ b/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj
@@ -73,6 +73,7 @@
+