Net Core MVC Middleware does not work after publish

133 Views Asked by At
app.Use((context, next) => {
            // Ignore requests that don't point to static files.
            if (context.Request.Path.StartsWithSegments("/Cvler"))
            {
                
                if (context.User.Identities.Any(identity => identity.HasClaim("pozisyon", "admin")))
                {
                    return next();
                }

                context.Response.StatusCode = 401;
                return Task.FromResult(0);
            }
            return next();
            // Stop processing the request and return a 401 response.

        });

Hi all, i want to hide CV folder from everyone except admin while development mode its working after publish middleware does not work everyone can see folder

1

There are 1 best solutions below

0
On

problem was i write app.usestaticfiles before middleware app.use