相关文章:ASP.NET Core 使用 Hangfire 定时任务
ASP.NET Core Hangfire 在正式环境发布之后,如果访问 http://10.1.2.31:5000/hangfire/ 的话,会报401 Unauthorized
未授权错误,原因是 Hangfire 默认增加了授权配置。
解决方式:
增加CustomAuthorizeFilter
:
public class CustomAuthorizeFilter : IDashboardAuthorizationFilter
{
public bool Authorize([NotNull] DashboardContext context)
{
//var httpcontext = context.GetHttpContext();
//return httpcontext.User.Identity.IsAuthenticated;
return true;
}
}
Configure
增加配置:
app.UseHangfireDashboard("/hangfire", new DashboardOptions() {
Authorization = new[] { new CustomAuthorizeFilter() }
本文转自田园里的蟋蟀博客园博客,原文链接:http://www.cnblogs.com/xishuai/p/asp-net-core-hangfire-401-unauthorized.html,如需转载请自行联系原作者