Base solution for your next web application
Open Closed

Hangfire App Path #1907


User avatar
0
maharatha created

Hi -

I have been trying to set the virtual absolute path and security in my startup.cs like the below :

app.UseHangfireDashboard("/BackgroundJobs", new DashboardOptions
            {
                Authorization = new[] { new AbpHangfireAuthorizationFilter(AppPermissions.Pages_Administration_Host_Hangfire) }
            });

            app.UseHangfireDashboard("/BackgroundJobs", new DashboardOptions
            {
                AppPath = VirtualPathUtility.ToAbsolute("~/Application/App")
            }
            );

The authorization works but the App path doesn't work. It always redirect to the root URL where as I am trying the user to redirect to the dashboard.

Am I doing it right ?


6 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    I don't know what AppPath does, but, in general, you shouldn't call UseHangfireDashboard twice. Why don't you write it like that:

    app.UseHangfireDashboard("/BackgroundJobs", new DashboardOptions
                {
                    Authorization = new[] { new AbpHangfireAuthorizationFilter(AppPermissions.Pages_Administration_Host_Hangfire) },
     AppPath = VirtualPathUtility.ToAbsolute("~/Application/App")
                });
    
  • User Avatar
    0
    maharatha created

    Thanks it worked.

    The AppPath is used to navigate back from the Hangfire Dashboard to the application

  • User Avatar
    0
    kythor created

    Any idea why AbpHangfireAuthorizationFilter is not recognized in my code?

    Abp.Hangfire is referenced and added as using.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Which ABP version do you use in your project ? AbpHangfireAuthorizationFilter introduced in ABP 0.11.

  • User Avatar
    0
    kythor created

    it seems to be version 0.10.3.1 So how to proceed? I'm not a fan of updating the dll's on my production environment. Any other simple way to get this to work? I just need one background job atm. but when I go to /backgroundjobs, it always redirects to the login page.

  • User Avatar
    0
    ismcagdas created
    Support Team

    You can upgrade to ABP v0.11 if you want to use AbpHangfireAuthorizationFilter. See it's release notes here <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/releases/tag/v0.11.0.0">https://github.com/aspnetboilerplate/as ... /v0.11.0.0</a>.

    It's the next version of your version, so you will not have much problems. We can help if you face any problems.