其他分享
首页 > 其他分享> > 本地可以正常打开hangfire页面,发布后报401

本地可以正常打开hangfire页面,发布后报401

作者:互联网

解决办法 增加CustomAuthorizeFilter
public class CustomAuthorizeFilter : IDashboardAuthorizationFilter
    {
        public bool Authorize([NotNull] DashboardContext context)
        {
            return true;
        }
        public CustomAuthorizeFilter()
        {            
        }
    }
新增类

Configure增加配置,代码也可以其他地方,用下面代码替换原先 app.UseHangfireDashboard() 即可。

  app.UseHangfireDashboard("/hangfire", new DashboardOptions
            {
                Authorization = new[] { new CustomAuthorizeFilter() }
            }); 

 

标签:CustomAuthorizeFilter,app,hangfire,后报,401,new,UseHangfireDashboard,public
来源: https://www.cnblogs.com/xbding/p/15099942.html