lundi 23 mai 2022

Get at method parameter attribute in Asp.NET Core ActionFilter through reflection

I have an IAsyncActionFilter and I'm intercepting a Controller Method that has a custom attribute on a parameter.

Controller: public async Task<ActionResult<ThingDto>> FindById([MyCustomAttribute] string id)

ActionFilter: public async Task OnActionExecutionAsync(ActionExecutingContext actionContext, ActionExecutionDelegate next)

I'd like to go from the ActionExecutingContext actionContext to this custom attribute - it feels like I'd go from actionContext.ActionDescriptor.MethodInfo.Signature - but I've rooted around in there for a while and nothing fits the bill. Can anyone help pinpoint where this would end up? I'm not able to find any resources on this particular kind of reflection.





Aucun commentaire:

Enregistrer un commentaire