{"record":{"id":"0c7b6079ade3fec9","repo":"HangfireIO/Hangfire","slug":"routes-0c7b60","errorCode":null,"errorMessage":"routes","messagePattern":"routes","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/Obsolete/DashboardMiddleware.cs","lineNumber":46,"sourceCode":"    internal sealed class DashboardMiddleware : OwinMiddleware\n    {\n        private readonly string _appPath;\n        private readonly int _statsPollingInterval;\n        private readonly JobStorage _storage;\n        private readonly RouteCollection _routes;\n        private readonly IEnumerable<IAuthorizationFilter> _authorizationFilters;\n\n        public DashboardMiddleware(\n            OwinMiddleware next,\n            string appPath,\n            int statsPollingInterval,\n            [NotNull] JobStorage storage,\n            [NotNull] RouteCollection routes, \n            [NotNull] IEnumerable<IAuthorizationFilter> authorizationFilters)\n            : base(next)\n        {\n            if (storage == null) throw new ArgumentNullException(nameof(storage));\n            if (routes == null) throw new ArgumentNullException(nameof(routes));\n            if (authorizationFilters == null) throw new ArgumentNullException(nameof(authorizationFilters));\n\n            _appPath = appPath;\n            _statsPollingInterval = statsPollingInterval;\n            _storage = storage;\n            _routes = routes;\n            _authorizationFilters = authorizationFilters;\n        }\n\n        public override Task Invoke(IOwinContext owinContext)\n        {\n            var dispatcher = _routes.FindDispatcher(owinContext.Request.Path.Value);\n            \n            if (dispatcher == null)\n            {\n                return Next.Invoke(owinContext);\n            }\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/Obsolete/DashboardMiddleware.cs#L28-L64","documentation":"Thrown as ArgumentNullException by the DashboardMiddleware constructor when the 'routes' RouteCollection argument is null. DashboardMiddleware is an internal OWIN middleware that wires the configured RouteCollection into the per-request dispatcher lookup; a null routes collection makes it impossible to resolve dashboard URLs, so the constructor fails fast.","triggerScenarios":"Instantiating DashboardMiddleware (directly or via the OWIN 'app.Use<DashboardMiddleware>(...)' pipeline) without supplying a non-null RouteCollection for the routes parameter. The OWIN activation layer injects constructor arguments positionally, so passing null or omitting the routes argument triggers line 46.","commonSituations":"Custom OWIN pipeline wiring that tries to register a dashboard middleware manually without forwarding DashboardRoutes.Routes; a refactor or version upgrade where the RouteCollection field was replaced by null; tests that mock the OWIN middleware graph with stub objects.","solutions":["Ensure the RouteCollection passed as the routes argument is non-null — normally DashboardRoutes.Routes from the Hangfire dashboard configuration.","Prefer the higher-level IAppBuilder.UseHangfireDashboard extension instead of registering DashboardMiddleware directly, so routes are wired for you.","If you maintain a custom route collection, verify it is constructed and assigned before the OWIN middleware is added to the pipeline."],"exampleFix":"// before\napp.Use<DashboardMiddleware>(appPath, storage, null, authFilters);\n\n// after\napp.Use<DashboardMiddleware>(appPath, storage, DashboardRoutes.Routes, authFilters);","handlingStrategy":"validation","validationCode":"if (routes == null) throw new ArgumentNullException(nameof(routes));\napp.Use<DashboardMiddleware>(appPath, storage, routes ?? DashboardRoutes.Routes, authFilters);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use IAppBuilder.UseHangfireDashboard instead of registering DashboardMiddleware directly so routes are always wired.","Keep a single source of truth for the dashboard RouteCollection (DashboardRoutes.Routes) and forward it everywhere."],"tags":["argument-null","owin","dashboard","configuration","internal-api"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}