Hangfire
Hangfire copied to clipboard
Hangfire Dashboard title or logo
Hi,
How to change Hangfire title? I want to put there company name or logo.
Is there an improvement in this issue?
B.R.
There's no easy solution for now, and I doubt custom re-branding will be available for the dashboard in open-source version.
there is a solution for .net core application, you just need to catch hangfire request and inject whatever you want, for example:
//in Startup
app.UseMiddleware<CustomHangfireFilter>();
//CustomHangfireFilter.cs
public class CustomHangfireFilter
{
private readonly RequestDelegate next;
public CustomHangfireFilter(RequestDelegate next)
{
this.next = next;
}
public async Task Invoke(HttpContext context)
{
if (context.Request.Path.Value.StartsWith("/hangfire/js")) //for example, you can catch js file
{
var newContent = string.Empty;
var existingBody = context.Response.Body;
using (var newBody = new MemoryStream())
{
context.Response.Body = newBody;
await next(context);
// Set the stream back to the original.
context.Response.Body = existingBody;
newBody.Seek(0, SeekOrigin.Begin);
newContent = new StreamReader(newBody).ReadToEnd();
newContent += @"
$(function(){
//use jQuery to append your custom html
});";
// Send our modified content to the response body.
await context.Response.WriteAsync(newContent);
}
}
else
{
await next(context);
}
}
}
For others looking for a workaround to change the title of a Hangfire dashboard, I've put together a simple library that does the job - same approach as above using a custom middleware to make the replacement. Works with ASP .NET Core apps as well as with Owin-based apps.
https://github.com/augustoproiete/hangfire-dashboard-customize
For others looking for a workaround to change the title of a Hangfire dashboard, I've put together a simple library that does the job - same approach as above using a custom middleware to make the replacement. Works with ASP .NET Core apps as well as with Owin-based apps.
https://github.com/caioproiete/hangfire-dashboard-customize
Pretty flawed logic. This would only work if hangfire is the only HTML page you are serving
Pretty flawed logic. This would only work if hangfire is the only HTML page you are serving
@caveofjulian I'm not sure what you were expecting, but your tone here is rude and completely uncalled for - unlike most users whom I do my very best to support, I'm happy I won't be needing to interact with you in the future 👋
@augustoproiete sorry, was just direct - not rude. It's good to point out because it causes bugs while that's totally unnecessary for this library.
@augustoproiete sorry, was just direct - not rude. It's good to point out because it causes bugs while that's totally unnecessary for this library.
So fix it instead of whining.
This issue should be closed, this feature was already added, although I'm not sure which version introduced it.
In the current release of Hangfire you can do this:
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapHangfireDashboard("/hangfire", new DashboardOptions
{
DashboardTitle = "My very cool title",
DarkModeEnabled = true
});
});
or
app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
DashboardTitle = "My even cooler title,
DarkModeEnabled = true
});
Of course you wanna use dark mode on both, won't work otherwise ;)
Yep thanks!