HangfireIO / Hangfire

An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
https://www.hangfire.io
Other
9.43k stars 1.71k forks source link

Fix UrlHelper.To in Obsolete case #2393

Closed LordJZ closed 5 months ago

LordJZ commented 7 months ago

The piece of code in question:

        public string To(string relativePath)
        {
            return _context.Options.PrefixPath +
                   (
#if FEATURE_OWIN
                       _owinContext?.Request.PathBase.Value ??
#endif
                       _context.Request.PathBase
                       + relativePath
                   );
        }

With FEATURE_OWIN this compiles to the following:

return _context.Options.PrefixPath +
    (_owinContext?.Request.PathBase.Value ??
        (_context.Request.PathBase + relativePath));

Note how in the Owin case the relativePath value is lost.

Not a big deal since the Owin case is deprecated via constructor attribute.

odinserj commented 5 months ago

Thanks @LordJZ, definitely makes sense!