Closed
Description
AddApiVersionRouteValueIfNecessary requires an HttpContext and is only called in methods that have one as an argument. It looks like this is intentional, but the result is that LinkGenerator doesn't return a value for calls that don't provide either:
- HttpContext as an argument
- Or the route value that was used as a version if URL Path Versioning is being used.
My specific case is ApiControllers that are calling GetPathByRouteValues(routeName, values), but I think it applies more broadly.
Versions
Microsoft.AspNetCore.Mvc.Versioning, 5.0.0
Microsoft.AspNetCore.App, 5.0.0
I'm working around this by using IHttpContextAccessor to get and pass the HttpContext, but that may not work for everyone (if services.AddHttpContextAccessor isn't called). I can create a minimal project that reproduces this if that's helpful.