HangfireIO / Hangfire

An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
https://www.hangfire.io
Other
9.43k stars 1.71k forks source link

AsyncAuthorization causes issues with Dashboard UI #2382

Open sinanilyas opened 8 months ago

sinanilyas commented 8 months ago

When I use AsyncAuthorization, it causes issues with the Dashboard UI.

Styles and scripts fails to load correctly, leading the graphics to disappear in the home page of the dashboard. In addition, trigger and delete buttons remain disabled when a recurring job is selected.

Here's my code:

var userManager = app.Services.GetRequiredService<IServiceScopeFactory>().CreateScope()
    .ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();

app.UseHangfireDashboard("/Hangfire", new DashboardOptions
{
    DashboardTitle = "Dashboard",
    DisplayStorageConnectionString = false,
    AppPath = "/App",
    AsyncAuthorization = new [] { new MyAsyncAuthorizationFilter(userManager) }
});

When I use Authorization instead of AsyncAuthorization as below, everything works fine.

var userManager = app.Services.GetRequiredService<IServiceScopeFactory>().CreateScope()
    .ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();

app.UseHangfireDashboard("/Hangfire", new DashboardOptions
{
    DashboardTitle = "Dashboard",
    DisplayStorageConnectionString = false,
    AppPath = "/App",
    Authorization = new [] { new MyAuthorizationFilter(userManager) }
});

I'm currently using ASP.NET 8.0.1 with Hangfire 1.8.11 Nuget package installed.