Skip to content

Simple way to configure route constraints. #729

Answered by grounzero
grounzero asked this question in Q&A
Discussion options

You must be logged in to vote

Rather than have ugly regex paths inside configuration files. I added a middleware to ignore specific routes. I quite like having the "Path": "{**catch-all}" with a catch all to ignore certain paths. If there is a nicer way I would be very interested to know but for the moment this appears to do the job it needs to.

    public class IgnoredRouteMiddleware
    {
        readonly RequestDelegate _next;
        readonly IgnoredRouteOptions _options;

        public IgnoredRouteMiddleware(RequestDelegate next, IgnoredRouteOptions options) =>
            (_next, _options) = (next, options);

        public async Task Invoke(HttpContext context)
        {
            if (_options.Routes.Any(route 

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@Tratcher
Comment options

Tratcher Feb 9, 2021
Collaborator

@grounzero
Comment options

Answer selected by grounzero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants