{"record":{"id":"0150e578e883ac40","repo":"HangfireIO/Hangfire","slug":"owinenvironment-0150e5","errorCode":null,"errorMessage":"owinEnvironment","messagePattern":"owinEnvironment","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/Obsolete/RequestDispatcherContext.cs","lineNumber":35,"sourceCode":"using System.Collections.Generic;\nusing System.Text.RegularExpressions;\nusing Hangfire.Annotations;\n\n// ReSharper disable once CheckNamespace\nnamespace Hangfire.Dashboard\n{\n    [Obsolete(\"Use the `DashboardContext` class instead. Will be removed in 2.0.0.\")]\n    public class RequestDispatcherContext\n    {\n        public RequestDispatcherContext(\n            string appPath,\n            int statsPollingInterval,\n            [NotNull] JobStorage jobStorage,\n            [NotNull] IDictionary<string, object> owinEnvironment,\n            [NotNull] Match uriMatch)\n        {\n            if (jobStorage == null) throw new ArgumentNullException(nameof(jobStorage));\n            if (owinEnvironment == null) throw new ArgumentNullException(nameof(owinEnvironment));\n            if (uriMatch == null) throw new ArgumentNullException(nameof(uriMatch));\n\n            AppPath = appPath;\n            StatsPollingInterval = statsPollingInterval;\n            JobStorage = jobStorage;\n            OwinEnvironment = owinEnvironment;\n            UriMatch = uriMatch;\n        }\n\n        public string AppPath { get; }\n        public int StatsPollingInterval { get; }\n        public JobStorage JobStorage { get; }\n        public IDictionary<string, object> OwinEnvironment { get; } \n        public Match UriMatch { get; }\n\n        public static RequestDispatcherContext FromDashboardContext([NotNull] DashboardContext context)\n        {\n            if (context == null) throw new ArgumentNullException(nameof(context));","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/Obsolete/RequestDispatcherContext.cs#L17-L53","documentation":"Thrown as ArgumentNullException by the obsolete RequestDispatcherContext constructor when the 'owinEnvironment' IDictionary<string,object> argument is null. The environment dictionary is the OWIN request environment that dispatchers read (path, user, etc.); a null environment makes request handling impossible, so the constructor rejects it at line 35.","triggerScenarios":"Constructing a RequestDispatcherContext with a null owinEnvironment — typically by calling FromDashboardContext when the source OwinDashboardContext.Environment is null (custom/mis-wired dashboard context), or by manually creating the context without forwarding the OWIN environment.","commonSituations":"A non-OWIN host (e.g. ASP.NET Core) accidentally routed through the OWIN-only RequestDispatcherContext path; a test or custom middleware that builds a dashboard context with a null environment dictionary; a malformed OWIN pipeline where the environment wasn't propagated.","solutions":["Use the modern DashboardContext / IDashboardDispatcher pipeline instead of the obsolete RequestDispatcherContext, which ties you to OWIN.","Ensure the OWIN environment dictionary is forwarded from the real IOwinContext.Environment when constructing the context.","In ASP.NET Core hosting, use the AspNetCore Hangfire dashboard package rather than the OWIN-based context."],"exampleFix":"// before — custom context with null environment\nvar ctx = new RequestDispatcherContext(appPath, interval, storage, null, match);\n\n// after — forward the real OWIN environment\nvar ctx = new RequestDispatcherContext(appPath, interval, storage, owinContext.Environment, match);","handlingStrategy":"validation","validationCode":"if (owinEnvironment == null) throw new ArgumentNullException(nameof(owinEnvironment));\nvar ctx = new RequestDispatcherContext(appPath, interval, storage, owinContext.Environment, match);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always forward the real IOwinContext.Environment, never null.","In non-OWIN hosts, use the platform-native Hangfire dashboard package instead."],"tags":["argument-null","dashboard","owin","environment","obsolete"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}