Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ApiVersionLinkGenerator methods that don't take HttpContext argument don't generate links #753

Copy link
Copy link
Closed
@dbroudy

Description

@dbroudy
Issue body actions

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.