I have .NET MVC application with OWIN Middleware.
The issue I'm facing right now is I'm not able by pass middleware logic for AllowAnonymous.
By default all the requests are forwarded to Middleware and I've to bypass some of the public requests from this middleware.
here is some of my code, it also contains commented code with what I tried so far.
public override async Task Invoke(IOwinContext context)
{
try
{
// I tried this below code but not able to make it working as my context is owin
// var anonActionAttributes = context.ActionDescriptor.GetCustomAttributes(typeof(System.Web.Mvc.AllowAnonymousAttribute), true);
// bool hasAllowAnonymous = context.ActionDescriptor.GetCustomAttributes(typeof(AllowAnonymousAttribute)).Any();
// var allowAnonymous = context.ActionDescriptor.EndpointMetadata.OfType<AllowAnonymousAttribute>().Any();
var token = context.Request.Cookies["token"];
if (!string.IsNullOrEmpty(token))
{
}
}
catch (Exception ex)
{
Log.Error(ex);
}
await Next.Invoke(context);
}