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).
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.
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();
});
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!
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?
Iāve updated to .net 6 recently so my app is running in the defaults i.e. Kestrel and Iāve just noticeback to site is having the same issue where it seems to strip the path. So my āsiteā is a separate app entirely running at https://my.site.com/app and hangfire runs on https://my.site.com/app/scheduler, but the back to site link is being rendered as https://my.site.com and so doesnāt work.
I probably wonāt be able to help, but I can do some testing locally and see if I can find anything to help. I do have a .NET 6.0 web app set up running Hangfire, but itās running at the root level. Can you let me know how you have configured your .NET 6 app to run as a sub-application? Are you only doing this on the server (in IIS) when you publish/deploy the app, or do you also have it set up to run as a sub-app in Visual Studio?
I figured it out, I already had the prefixed ā/ā however the new MapDashboard and UseDashboard were double registering the dashboard and consequently overwriting the configuration. I removed UseDashboard in favour of MapDashboard and all is well.