hangfire - Hangfire 仪表板授权重定向以登录
问题描述
我已将 Hangfire 添加到 dotnetcore 项目中。我添加了仪表板授权过滤器。
public class HangfireDashboardAuthorizationFilter : IDashboardAuthorizationFilter
{
public bool Authorize(DashboardContext context)
{
var httpContext = context.GetHttpContext();
if (!httpContext.User.Identity.IsAuthenticated)
{
return false;
}
var userRole = httpContext.User.FindFirst(ClaimTypes.Role)?.Value;
return userRole == Roles.Administrator.ToDisplayName();
}
}
这工作正常。但是当用户未经授权时,我只会收到 401。它不会重定向到我的登录页面。如何使此过滤器导致重定向?
解决方案
推荐阅读
- python - 如何使用 seleinum 点击某物?javascript:void(0) 蟒蛇
- python - 在 Pandas 中具有重复索引且没有聚合函数的数据透视表
- java - 使用java从路径创建JSON
- sql - 存储过程参数检查非空字符串
- azure - 尝试向 Azure 订阅添加其他所有者时的奇怪现象
- swift - 使用 Charts API Swift 显示时间戳
- angular - RouterModule.forRoot() 再次调用了两次
- angular - 日期验证,以便不选择下一个日期
- reactjs - 如果语句在 componentDidUpdate 的开玩笑测试中失败
- r - 在 R 中读取一个非常小的 p 值