HangfireIO/Hangfire · error · ArgumentNullException
owinEnvironment
Error message
owinEnvironment
What it means
The obsolete UrlHelper constructor taking an OWIN environment dictionary (UrlHelper.cs:30) throws ArgumentNullException when owinEnvironment is null. The constructor wraps the dictionary in an OwinContext for request path resolution. This overload is deprecated in favor of UrlHelper(DashboardContext).
Source
Thrown at src/Hangfire.Core/Dashboard/UrlHelper.cs:30
//
// You should have received a copy of the GNU Lesser General Public
// License along with Hangfire. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using Hangfire.Annotations;
namespace Hangfire.Dashboard
{
public class UrlHelper
{
#if FEATURE_OWIN
private readonly Microsoft.Owin.OwinContext _owinContext;
[Obsolete("Please use UrlHelper(DashboardContext) instead. Will be removed in 2.0.0.")]
public UrlHelper([NotNull] IDictionary<string, object> owinEnvironment)
{
if (owinEnvironment == null) throw new ArgumentNullException(nameof(owinEnvironment));
_owinContext = new Microsoft.Owin.OwinContext(owinEnvironment);
}
#endif
private readonly DashboardContext _context;
public UrlHelper([NotNull] DashboardContext context)
{
if (context == null) throw new ArgumentNullException(nameof(context));
_context = context;
}
public string To(string relativePath)
{
return _context.Options.PrefixPath +
(
#if FEATURE_OWIN
_owinContext?.Request.PathBase.Value ??View on GitHub (pinned to c236dd0f93)
Solutions
- Migrate to the UrlHelper(DashboardContext) constructor which is the supported API.
- If keeping the OWIN overload, ensure the environment dictionary is non-null.
Example fix
// before (obsolete OWIN overload) var helper = new UrlHelper(owinEnv); // owinEnv may be null // after (supported overload) var helper = new UrlHelper(dashboardContext);
Defensive patterns
Strategy: validation
Validate before calling
if (owinEnvironment == null)
throw new ArgumentNullException(nameof(owinEnvironment));
var helper = new UrlHelper(owinEnvironment); Prevention
- Migrate to the UrlHelper(DashboardContext) constructor (supported API).
- Ensure the OWIN environment dictionary is non-null if using the obsolete overload.
When it happens
Trigger: Instantiating new UrlHelper(null) via the OWIN dictionary overload, or passing a variable that resolved to null.
Common situations: Legacy OWIN-based dashboard middleware passing a null environment; migrating from OWIN to ASP.NET Core and the environment dictionary is no longer available.
Related errors
AI-assisted analysis of HangfireIO/Hangfire@c236dd0f93 (2026-08-13).
Data as JSON: /api/errors/680d02d2d6825a2a.
Report an issue: GitHub.