Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

How to access Hangfire dashboard in AspNetCore project? #5411


User avatar
0
ajayak created

I have followed all the steps mentioned in <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Hangfire-Integration">https://aspnetboilerplate.com/Pages/Doc ... ntegration</a> for hangfire integration in .Net Core solution.

When I goto projectUrl/hangfire, I see the error: This page isn’t working If the problem continues, contact the site owner. HTTP ERROR 401

How can I view this page, with Authorization enabled?


8 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    By default: Log in to the system and the current user has the "AppPermissions.Pages_Administration_HangfireDashboard" permission.

    Which project are you using in the HangfireDashboard? XXX.MVC or XXX.Host?

  • User Avatar
    0
    ajayak created

    Hi @malming, I'm using the Web.Host project.

    If I comment the permission section, I am able to view the hangfire dashboard. But I have no idea how to access the dashboard with the authentication enabled.

  • User Avatar
    0
    maliming created
    Support Team

    This is my practice, for reference only. Use razor pages to write a simple login function page. Then use cookie authorization. Now you can access the hangfire page that requires authorization.

    Simple code:

    public async Task<ActionResult> OnGet()
    {
       using (var uow = _unitOfWorkManager.Begin())
       {
          var loginResult = await _logInManager.LoginAsync("admin", "qq1234", "Default");
          if (loginResult.Result == AbpLoginResultType.Success)
          {
             await _signInManager.SignInAsync(loginResult.User, true);
          }
    
          uow.Complete();
          return Page();
       }
    }
    
  • User Avatar
    0
    alper created
    Support Team

    Hi,

    The docs explain how to authorize HangFire Dashboard; <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Hangfire-Integration#dashboard-authorization">https://aspnetboilerplate.com/Pages/Doc ... horization</a>

    See the related posts; <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1245">https://github.com/aspnetboilerplate/as ... ssues/1245</a> <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1971">https://github.com/aspnetboilerplate/as ... ssues/1971</a>

  • User Avatar
    0
    ajayak created

    <cite>alper: </cite> Hi,

    The docs explain how to authorize HangFire Dashboard; <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Hangfire-Integration#dashboard-authorization">https://aspnetboilerplate.com/Pages/Doc ... horization</a>

    See the related posts; <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1245">https://github.com/aspnetboilerplate/as ... ssues/1245</a> <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1971">https://github.com/aspnetboilerplate/as ... ssues/1971</a>

    Hi @alper,

    I am using Hangfire in Web.Host solution not the MVC project. I am able to access the hangfire dashboard when I comment the hangfire authorization filter. But I cannot find a good way to access the hangfire dashboard when Authorization filter is added.

    I believe this should be an inbuilt feature in AspNetZero template.

  • User Avatar
    0
    BobIngham created

    aspnet-core, angular; 5.4.1 Everyone seems to suggest that displaying the Hangfire dashboard is easy but I have not yet found a way to do it using the aspnet-core/angular project. I understand that the dashboard requires cookies and all the solutions for adding cookies to authentication seem like overkill. The method outline by Caskia at [https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1971]) seemed to suggest a way forward but the code outlined is deprecated. I do not want to use authentication and the following two lines of code:

    app.UseHangfireDashboard("/hangfire");
    app.UseHangfireServer();
    

    when placed in the Web.Host project simply redirect me back to the fallback route (<a class="postlink" href="http://localhost:4200/app/notifications">http://localhost:4200/app/notifications</a>) when the route <a class="postlink" href="http://localhost:4200/hangfire">http://localhost:4200/hangfire</a> is entered directly into the browser.

    Can anyone help with some sample code please?

  • User Avatar
    0
    ismcagdas created
    Support Team

    We will work on that with this issue <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/issues/1457">https://github.com/aspnetzero/aspnet-ze ... ssues/1457</a>. Currently I don't know how to do this in Angular right now. You can use @maliming's suggestion as a temporary solution.

  • User Avatar
    0
    BobIngham created

    Thanks @ismcagdas. I will follow the issue.