'How to skip endpoint from middleware processing in asp.net framework

I created an owin middleware for asp.net framework. I want to mark some endpoints (methods of controller) to skip them from middleware processing.

For asp core I did it with simple attribute and from middleware's Invoke use

var endpoint = context.Features.Get<IEndpointFeature>()?.Endpoint;
var attribute = endpoint?.Metadata.GetMetadata<SkipFromAnalyzeAttribute>();
if (attribute != null) { await next(context); return; }

But in asp framework I can't do something like this. I tried to use inherit from ActionFilterAttribute and set custom header, so that later in the Invoke of middleware it can be used to determine should it be skipped or not, but its OnActionExecuting invoke after middleware's Invoke.

Have someone an idies how can I resolve this trouble?)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source