首页 > 解决方案 > Net Core MVC 中间件在发布后不起作用

问题描述

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.

        });

大家好,我想对除管理员之外的所有人隐藏 CV 文件夹,而开发模式下它在发布中间件后的工作不起作用每个人都可以看到文件夹

标签: c#.netmiddlewarenetcoreapp3.1

解决方案


问题是我在中间件 app.use 之前写 app.usestaticfiles


推荐阅读