public IEnumerable <System.Web.Mvc.Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) { //if ((controllerContext.Controller is ProductController || controllerContext.Controller is ProductsController) && // actionDescriptor.ActionName.Equals("ProductList", // StringComparison.InvariantCultureIgnoreCase)) if ((actionDescriptor.ControllerDescriptor.ControllerName == "Product" || actionDescriptor.ControllerDescriptor.ControllerName == "Products") && actionDescriptor.ActionName.Equals("ProductList", StringComparison.InvariantCultureIgnoreCase)) { if (controllerContext.RouteData.Values["area"] != null && (controllerContext.RouteData.Values["area"].ToString() == "Admin" || controllerContext.RouteData.Values["area"].ToString() == "Vendor")) { //return new List<System.Web.Mvc.Filter>() { new System.Web.Mvc.Filter(this, FilterScope.Action, 0) }; } } if ((actionDescriptor.ControllerDescriptor.ControllerName == "Home") && actionDescriptor.ActionName.Equals("Index", StringComparison.InvariantCultureIgnoreCase)) { return(new List <System.Web.Mvc.Filter>() { new System.Web.Mvc.Filter(this, FilterScope.Action, 0) }); } var a = actionDescriptor.GetCustomAttributes(true); var b = actionDescriptor.GetFilterAttributes(true); var c = actionDescriptor.GetParameters(); return(new List <System.Web.Mvc.Filter>()); }
public IEnumerable <Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) { var filters = actionDescriptor.GetFilterAttributes(true); bool disableAntiForgery = filters.Any(f => f is DisableAntiForgeryCheckAttribute); string method = controllerContext.HttpContext.Request.HttpMethod; if (!disableAntiForgery && string.Equals(method, HttpMethod.Post.Method, StringComparison.OrdinalIgnoreCase)) { yield return(new Filter(new ValidateAntiForgeryTokenAttribute(), FilterScope.Global, null)); } }
public IEnumerable <FilterAttribute> GetActionFilterAttributes(ActionDescriptor actionDescriptor) { if (actionDescriptor == null) { throw new ArgumentNullException(nameof(actionDescriptor)); } if (actionDescriptor.Action == null) { throw new ArgumentNullException(nameof(actionDescriptor.Action)); } var action = actionDescriptor.Action; _sync.Enter(); _actionFilters.TryGetValue(action, out var filterAttributes); _sync.Exit(); if (filterAttributes != null) { return(filterAttributes); } filterAttributes = actionDescriptor.GetFilterAttributes()?.ToList(); if (filterAttributes == null && filterAttributes.Count > 0) { return(null); } _sync.Enter(); _actionFilters[action] = filterAttributes; _sync.Exit(); return(filterAttributes); }
public override IEnumerable <FilterAttribute> GetFilterAttributes(bool useCache) { return(Inner.GetFilterAttributes(useCache)); }