diff options
Diffstat (limited to 'src/System.Web.Mvc/ChildActionOnlyAttribute.cs')
-rw-r--r-- | src/System.Web.Mvc/ChildActionOnlyAttribute.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/System.Web.Mvc/ChildActionOnlyAttribute.cs b/src/System.Web.Mvc/ChildActionOnlyAttribute.cs new file mode 100644 index 00000000..16647f4a --- /dev/null +++ b/src/System.Web.Mvc/ChildActionOnlyAttribute.cs @@ -0,0 +1,19 @@ +namespace System.Web.Mvc +{ + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] + public sealed class ChildActionOnlyAttribute : FilterAttribute, IAuthorizationFilter + { + public void OnAuthorization(AuthorizationContext filterContext) + { + if (filterContext == null) + { + throw new ArgumentNullException("filterContext"); + } + + if (!filterContext.IsChildAction) + { + throw Error.ChildActionOnlyAttribute_MustBeInChildRequest(filterContext.ActionDescriptor); + } + } + } +} |