HangfireIO/Hangfire · error · ArgumentNullException
storage
Error message
storage
What it means
Thrown by the obsolete DashboardMiddleware constructor (OWIN-based) when the storage parameter is null. The middleware needs a JobStorage instance to serve dashboard pages and fetch monitoring data; a null storage makes all dashboard requests fail.
Source
Thrown at src/Hangfire.Core/Obsolete/DashboardMiddleware.cs:45
{
internal sealed class DashboardMiddleware : OwinMiddleware
{
private readonly string _appPath;
private readonly int _statsPollingInterval;
private readonly JobStorage _storage;
private readonly RouteCollection _routes;
private readonly IEnumerable<IAuthorizationFilter> _authorizationFilters;
public DashboardMiddleware(
OwinMiddleware next,
string appPath,
int statsPollingInterval,
[NotNull] JobStorage storage,
[NotNull] RouteCollection routes,
[NotNull] IEnumerable<IAuthorizationFilter> authorizationFilters)
: base(next)
{
if (storage == null) throw new ArgumentNullException(nameof(storage));
if (routes == null) throw new ArgumentNullException(nameof(routes));
if (authorizationFilters == null) throw new ArgumentNullException(nameof(authorizationFilters));
_appPath = appPath;
_statsPollingInterval = statsPollingInterval;
_storage = storage;
_routes = routes;
_authorizationFilters = authorizationFilters;
}
public override Task Invoke(IOwinContext owinContext)
{
var dispatcher = _routes.FindDispatcher(owinContext.Request.Path.Value);
if (dispatcher == null)
{
return Next.Invoke(owinContext);
}View on GitHub (pinned to c236dd0f93)
Solutions
- Use the modern app.UseHangfireDashboard() extension method instead of constructing DashboardMiddleware directly
- If constructing manually, pass JobStorage.Current (ensure it is set first via UseStorage)
- Ensure the OWIN startup class runs after storage configuration
Example fix
// before
app.Use(typeof(DashboardMiddleware), next, "/app", 2000, null, routes, filters);
// after
// Register storage first
GlobalConfiguration.Configuration.UseSqlServerStorage(connStr);
// Use the extension method
app.UseHangfireDashboard("/hangfire"); Defensive patterns
Strategy: validation
Validate before calling
var storage = JobStorage.Current; // ensure initialized first
if (storage == null) throw new InvalidOperationException("JobStorage not configured.");
var middleware = new DashboardMiddleware(next, appPath, interval, storage, routes, authFilters); Type guard
storage != null && storage is JobStorage
Prevention
- Use the modern app.UseHangfireDashboard() extension instead of constructing DashboardMiddleware directly
- Ensure JobStorage.Current is set before OWIN pipeline construction
- Migrate from the obsolete OWIN middleware to the current DashboardMiddleware if still on OWIN
When it happens
Trigger: Constructing new DashboardMiddleware(next, appPath, interval, null, routes, authFilters) or an OWIN pipeline registration that passes null for the JobStorage.
Common situations: Using the obsolete OWIN middleware directly (instead of the recommended app.UseHangfireDashboard extension), where JobStorage.Current has not been set yet at pipeline construction time, or a misconfigured OWIN startup class.
Related errors
AI-assisted analysis of HangfireIO/Hangfire@c236dd0f93 (2026-08-13).
Data as JSON: /api/errors/23a9cdc12e33482b.
Report an issue: GitHub.