Dashboard URL issues when deployed below site root

Tags: #<Tag:0x00007fe1d6700bb0>

There seem to be a few problems with the dashboard with regards to URLs when the hosting application is deployed in a virtual folder/subdirectory (http://domain.com/app) instead of the site root (http://domain.com).

  1. When the server is configured to use a different dashboard path than the default (/hangfire) using the app.UseDashboardPath() method, the dashboard cannot be reached. When you navigate to the configured dashboard URL, a 404 error is returned by the server. If the dashboard path is left as default, it can be reached as expected.

  2. When a user clicks the ‘Return to site’ link in the navigation bar within the dashboard, it navigates the user to the site root (http://domain.com).

If there is something else I need to consider to correctly configure the dashboard and return links to be reachable from a path other than default inside a virtual folder under site root, please let me know. Thank you.

The relevant snippet of my OWIN startup code follows:

app.UseHangfire(config =>
{
    config.UseSqlServerStorage("DbContext");
    config.UseNinjectActivator(new Bootstrapper().Kernel);

    // set path to Hangfire Dashboard
    config.UseDashboardPath(VirtualPathUtility.ToAbsolute("~/BackgroundJobs"));          

    // only users with Administrator role are authorized to access the Hangfire Dashboard
    config.UseAuthorizationFilters(new AuthorizationFilter { Roles = "Administrator" });

    // activate Hangfire background job server (for executing jobs)
    config.UseServer();
});

Scheduled this feature to 1.4.0

Great - that should resolve my issue #2. Do you have any input on my issue #1, or is this an issue also being addressed in 1.4.0?

Have you tried to use UseDashboardPath("/BackgroundJobs") instead of VirtualPathUtility? Dashboard is plugged in as an OWIN middleware, and VirtualPathUtility can be unnecessary for that.

Indeed, configuring it using the path “/BackgroundJobs” worked fine. Upon a closer look, I found that the problem was that I was trying to build a hyperlink in my UI to the dashboard using the same string value the dashboard path was configured with. In cases where the app is deployed to the site root, this works fine - but breaks down when deployed in a folder below the root.

I resolved my issue by configuring my dashboard path as “/BackgroundJobs” and building my hyperlink using that string with a “~” appended so that it can be reached regardless of where it is deployed.

Thanks for the assistance, and I look forward to 1.4.0. Great product!

1 Like

This is the exact problem I am having too. However I am not using OWIN but instead I am using the HangfireBootStrapper class from http://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html

How can I map the path to a sub application if I am not using OWIN?

Hi gdereese,

Could you please share me for How to change hyperlink to using that string with a “~” appended that you fixed on your application?

Many Many Thanks.
Nantanart.

2 Likes

I’m also at a loss here. My web app has the URL https://ServerAddress/MyWebApp, so when I click “Back to site” from the Dashboard, it returns https://ServerAddress only.
I’m using .NET 5. Can I get info on how to correctly configure the Back to site button?