c# - 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 文件夹,而开发模式下它在发布中间件后的工作不起作用每个人都可以看到文件夹
解决方案
问题是我在中间件 app.use 之前写 app.usestaticfiles
推荐阅读
- android - 旋转回纵向并调用 notifyDataSetChanged 后,Android RecyclerViewAdapter 项目宽度错误
- c++ - 如何在两棵树共有的函数中创建参数?
- ansible - 如何在ansible中循环条件字典
- python - 爆炸和拆分列导致数据不匹配
- java - OpenGLES“顶点属性索引超出边界”错误,尽管渲染效果很好
- doctrine-orm - 使用计数进行子查询
- python - 我已经包含了我遇到的错误图像
- node.js - 多对多关联抛出“A 未关联到 B”错误
- ios - 在 swiftUI 中是否可以使用按钮在屏幕上添加新视图?
- php - PHP数据没有返回,但它确实死了