Liunx下部署hangfire无法打开面板

若没有hangfir面板的过滤器IDashboardAuthorizationFilter,在打开/hangfire路径时请求会返回401未授权。
需要添加类继承IDashboardAuthorizationFilter过滤器类

    public class CustomerHangfireDashboardFilter : IDashboardAuthorizationFilter
    {
        public bool Authorize([NotNull] DashboardContext context)
        {

            return true;
        }
    }
并且在StartUp注册使用
app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
//hangfire 身份验证过滤器
Authorization = new[] { new CustomerHangfireDashboardFilter() },
});

 

posted @ 2023-09-14 17:25  黄明辉  阅读(50)  评论(0编辑  收藏  举报