Tel Map

Blog

Hangfire Dashboard and ASP .NET 5

This article demonstrates how the Hangfire dashboard can be set up in an ASP .NET 5 application including authentication via ASP .NET Identity.

Adding Hangfire Packages

project.json:

Since I am using Hangfire with SQL, I have to add Hangfire itself and Hangfire.SqlServer to the project.json.

Configuring Hangfire Dashboard

In order to be able to use the Hangfire dashboard we have to configure it in the Configure method in Startup.cs.

First we are defining under which URL Hangfire will be available, secondly we add a new Authorization Filter to Hangfire in order to authenticate users using ASP .NET Identity. Therefore we use an IHttpContextAccessor in the constructor of the filter in order to get access to authentication information. The parameter contextAccessor can simply be added to the method and will automatically be injected by the ASP .NET Dependency Injection.

The filter provided below, will simply check if the person accessing the Hangfire dashboard is authenticated.

Of course you could also check for claims and roles in the Authorize method.

Summary

This article demonstrates how to add the Hangfire dashboard to an ASP .NET 5 application with authentication using ASP .NET Identity.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert