{"record":{"id":"cdc0cc7b65b3027d","repo":"HangfireIO/Hangfire","slug":"context-cdc0cc","errorCode":null,"errorMessage":"context","messagePattern":"context","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Hangfire.Core/Dashboard/UrlHelper.cs","lineNumber":39,"sourceCode":"{\n    public class UrlHelper\n    {\n#if FEATURE_OWIN\n        private readonly Microsoft.Owin.OwinContext _owinContext;\n\n        [Obsolete(\"Please use UrlHelper(DashboardContext) instead. Will be removed in 2.0.0.\")]\n        public UrlHelper([NotNull] IDictionary<string, object> owinEnvironment)\n        {\n            if (owinEnvironment == null) throw new ArgumentNullException(nameof(owinEnvironment));\n            _owinContext = new Microsoft.Owin.OwinContext(owinEnvironment);\n        }\n#endif\n\n        private readonly DashboardContext _context;\n\n        public UrlHelper([NotNull] DashboardContext context)\n        {\n            if (context == null) throw new ArgumentNullException(nameof(context));\n            _context = context;\n        }\n\n        public string To(string relativePath)\n        {\n            return _context.Options.PrefixPath +\n                   (\n#if FEATURE_OWIN\n                       _owinContext?.Request.PathBase.Value ??\n#endif\n                       _context.Request.PathBase\n                   ) + relativePath;\n        }\n\n        public string Home()\n        {\n            return To(\"/\");\n        }","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/HangfireIO/Hangfire/blob/c236dd0f930f831ec151e436e138ddc429a02a72/src/Hangfire.Core/Dashboard/UrlHelper.cs#L21-L57","documentation":"The UrlHelper(DashboardContext) constructor (UrlHelper.cs:39) throws ArgumentNullException when context is null. The helper needs a DashboardContext to resolve the request path base and options prefix for URL generation throughout the dashboard.","triggerScenarios":"Instantiating new UrlHelper(null) via the DashboardContext overload.","commonSituations":"Custom dashboard page or middleware passing a null DashboardContext; context variable not yet initialized at the call site.","solutions":["Ensure a valid DashboardContext is passed; obtain it from the dashboard request pipeline rather than constructing separately.","Defer UrlHelper creation until the DashboardContext is available."],"exampleFix":"// before\nvar helper = new UrlHelper(null);\n\n// after\nvar helper = new UrlHelper(dashboardContext);","handlingStrategy":"validation","validationCode":"if (context == null)\n    throw new ArgumentNullException(nameof(context));\nvar helper = new UrlHelper(context);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Obtain DashboardContext from the dashboard request pipeline, not by manual construction.","Defer UrlHelper creation until the context is available."],"tags":["dashboard","argument-null","url-helper"],"backgroundTag":null,"analyzedSha":"c236dd0f930f831ec151e436e138ddc429a02a72","analyzedAt":"2026-08-13T20:27:11.027Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}