Hangfire icon indicating copy to clipboard operation
Hangfire copied to clipboard

Hangfire Dashboard title or logo

Open HakanKaraoglu opened this issue 6 years ago • 7 comments

Hi,

How to change Hangfire title? I want to put there company name or logo.

Is there an improvement in this issue?

B.R.

HakanKaraoglu avatar Dec 05 '18 11:12 HakanKaraoglu

There's no easy solution for now, and I doubt custom re-branding will be available for the dashboard in open-source version.

odinserj avatar Jan 14 '19 14:01 odinserj

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);
            }
        }
}

ivanvoitovych avatar Jul 03 '19 14:07 ivanvoitovych

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

hangfire-dashboard-customize

augustoproiete avatar Jul 13 '19 01:07 augustoproiete

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

hangfire-dashboard-customize

Pretty flawed logic. This would only work if hangfire is the only HTML page you are serving

caveofjulian avatar Apr 12 '21 18:04 caveofjulian

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 avatar Apr 12 '21 19:04 augustoproiete

@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.

caveofjulian avatar Apr 19 '21 22:04 caveofjulian

@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.

riaadh avatar Jul 25 '22 14:07 riaadh

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 ;)

brodrigz avatar Mar 11 '24 17:03 brodrigz

Yep thanks!

odinserj avatar Mar 13 '24 03:03 odinserj