Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Conditional Middleware

$
0
0

If I have [Authorize] turned on for all controllers and methods via configuration and have a custom middleware that I have up and running as well.

What I would like, is to make a particular middleware run conditionally based on whether the method that is to be run is marked [AllowAnonymous].  If the method is marked [AllowAnonymous], I do NOT want to run the middleware.  

It looks like UseWhen might be the answer but I can't seem to figure out how to make it work. 

Any help is appreciated.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>