I have seen how to do this globally in numerous posts and work in my code. The problem is that it launches an EVERY call, which is not what I want, I only want it to make calls to methods, where I decorated the method with an attribute:
public class MyController : ApiController
{
[MyAttribute]
public void MethodA()
{
}
public void MethodB()
{
}
}
It seems to me really basic, and that I am missing something, but the only way I can get the attribute is to register it global.asaxwith the help GlobalConfiguration.Configuration.Filters.Add(new MyAttribute());that forces it to run queries on both MethodAand MethodB. Is there a way to register an attribute and only fire by the methods where it is marked? I tried to use to AttributeUsageno avail.
EDIT , . ...
[AttributeUsage(AttributeTargets.Method)]
public class MyAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext actionContext)
{
}
}
11/25
, , , ActionDescriptorFilterProvider , , :
var providers = GlobalConfiguration.Configuration.Services.GetFilterProviders();
var defaultprovider = providers.First(i => i is ActionDescriptorFilterProvider);
GlobalConfiguration.Configuration.Services.Remove(typeof(System.Web.Http.Filters.IFilterProvider), defaultprovider);