I have a custom attribute and I use it in my action methods. I need to access this attribute information in delegation handler.
Controller A
{
[MyAttribute]
public IHttpActionResult MyMethod
}
public class MyHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
var controllerSelector = GlobalConfiguration.Configuration.Services.GetHttpControllerSelector();
var controllerDescriptor = controllerSelector.SelectController(request);
//Here I want to access controllerA action method MyMethod metadata
//so I can check if actionmethod has custom attribute or not and do my process
}
}
Here I want to access controllerA
action method MyMethod
metadata so I can check if actionmethod has custom attribute or not and do my process. Please advise me on this.
I use a little bit different approach,
I use GlobalConfiguration.Configuration.Services.GetApiExplorer().ApiDescriptions and match it from request.RequestUri