# Blazor Server project not registering hangfire route in IIS production environment

**URL:** <https://discuss.hangfire.io/t/blazor-server-project-not-registering-hangfire-route-in-iis-production-environment/10297>\
**Category:** bug?\
**Tags:** dashboard, aspnetcore\
**Created:** [October 20, 2023, 12:26pm UTC](https://discuss.hangfire.io/t/blazor-server-project-not-registering-hangfire-route-in-iis-production-environment/10297 "2023-10-20T12:26:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterEngineer](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@PeterEngineer](https://discuss.hangfire.io/u/PeterEngineer)\
**Post date:** [October 20, 2023, 12:26pm UTC](https://discuss.hangfire.io/t/blazor-server-project-not-registering-hangfire-route-in-iis-production-environment/10297/1 "2023-10-20T12:26:12Z")

</div>

When deploying a release build of my Blazor Server app and hosting it with IIS, the `/hangfire` endpoint is caught by the default Blazor routing as “not found”. However, it is working locally, in debug mode, using IIS Express.

How do I get the hangfire dashboard to work on a Blazor Server app in IIS on a server?

**Implementation**

```csharp
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddHangfire(x =>
{
    x.UseSqlServerStorage(builder.Configuration.GetConnectionString("DefaultConnection"), new SqlServerStorageOptions
    {
        PrepareSchemaIfNecessary = true,
    });
    x.UseConsole();
});

builder.Services.AddHangfireServer();

```

```csharp
var app = builder.Build();
app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
    Authorization = new[]
    {
        new HangfireCustomBasicAuthenticationFilter{
            User = "test",
            Pass = "test"
        }
    }
});

app.UseEndpoints(endpoints =>
{
    endpoints.MapControllers();
    endpoints.MapBlazorHub();
    endpoints.MapHangfireDashboard();
    endpoints.MapFallbackToPage("/_Host");
});

```

---

<div class="post-metadata">

**Author:** ![Tieson\_Trowbridge](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.hangfire.io/tieson_trowbridge/32/2895_2.png) [@Tieson\_Trowbridge](https://discuss.hangfire.io/u/Tieson_Trowbridge)\
**Post date:** [October 28, 2023, 4:13am UTC](https://discuss.hangfire.io/t/blazor-server-project-not-registering-hangfire-route-in-iis-production-environment/10297/2 "2023-10-28T04:13:18Z")

</div>

Just a guess, since I don’t code in Blazor, but this line is probably overwriting your `UseHangfireDashboard` settings:

> endpoints.MapHangfireDashboard();

Everything else in your configuration seems correct, based on how I have Hangfire configured in an [ASP.NET](http://ASP.NET) 6 app.

I’m basing this assumption off a very quick glance at the source code for this extension method, for here: [https://github.com/HangfireIO/Hangfire/blob/98193fa12d2681661fe852eed72e16eb57653fc0/src/Hangfire.AspNetCore/HangfireEndpointRouteBuilderExtensions.cs#L30](https://github.com/HangfireIO/Hangfire/blob/98193fa12d2681661fe852eed72e16eb57653fc0/src/Hangfire.AspNetCore/HangfireEndpointRouteBuilderExtensions.cs#L30)

---

<div class="post-metadata">

**Author:** ![PeterEngineer](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@PeterEngineer](https://discuss.hangfire.io/u/PeterEngineer)\
**Post date:** [October 30, 2023, 8:51am UTC](https://discuss.hangfire.io/t/blazor-server-project-not-registering-hangfire-route-in-iis-production-environment/10297/3 "2023-10-30T08:51:53Z")

</div>

I used only `endpoints.MapHangfireDashboard()`. then only `app.UseHangfireDashboard()` and vice versa, did not fix the issue.

Setting `IgnoreAntiforgeryToken = true` for the dashboard seems to have fixed the issue. Perhaps Blazor Server and Hangfire use conflicting or different Anti Forgery Tokens when enabling security?

- Removed using endpoints
- Added `IgnoreAntiforgeryToken = true`
- Removed Authorization for Dashboard as this was also not working

**Working implementation Blazor Server**

```auto
app.UseHttpsRedirection();

app.UseRouting();

app.UseAuthentication();
app.UseAuthorization();

app.MapControllers();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");

app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
    IgnoreAntiforgeryToken = true,
});

```
