AbpZero框架已经集成了hangfire,但它默认是关闭的,我们可以在运行站点下的Startup.cs文件中把这行代码注释取消就行了,代码如下:
//Hangfire (Enable to use Hangfire instead of default job manager)
services.AddHangfire(config =>
{
config.UseSqlServerStorage(_appConfiguration.GetConnectionString("Default"));
});
//Hangfire dashboard & server (Enable to use Hangfire instead of default job manager)
app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
// Authorization = new[] { new AbpHangfireAuthorizationFilter(AppPermissions.Pages_Administration_HangfireDashboard) }
Authorization = new[] { new CustomAuthorizeFilter() }
});
app.UseHangfireServer();
运行swagger后,把链接改为:http://localhost:22742/hangfire,即可调出hangfire后台作业管理页面。