You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The IApiVersioningFeature is only allocated and assigned once per request. The original expectation was that the middleware would only be entered a single time and if re-entered, it should be idempotent. When the legacy routing system (e.g. IRouter) is used with API Versioning in ASP.NET Core, the IApiVersioningFeature.SelectionResult becomes stateful for the entire request. If the pipeline, and hence all the middleware, runs more than once, the IApiVersioningFeature.SelectionResult should be cleared or otherwise reset. Failure to do so can result in the incorrect action being selected at the end. This could also result in an ambiguous match result.
Enhancement
Clear any previous values in IApiVersioningFeature.SelectionResult each time the middleware is entered.
Workaround
This problem can currently be worked around by explicitly reinitializing the IApiVersioningFeature instance with custom middleware as follows:
NOTE: This only applies to the legacy routing system. Endpoint Routing is unaffected by this because it does not use IApiVersioningFeature.SelectionResult.
The text was updated successfully, but these errors were encountered:
Background
The
IApiVersioningFeature
is only allocated and assigned once per request. The original expectation was that the middleware would only be entered a single time and if re-entered, it should be idempotent. When the legacy routing system (e.g.IRouter
) is used with API Versioning in ASP.NET Core, theIApiVersioningFeature.SelectionResult
becomes stateful for the entire request. If the pipeline, and hence all the middleware, runs more than once, theIApiVersioningFeature.SelectionResult
should be cleared or otherwise reset. Failure to do so can result in the incorrect action being selected at the end. This could also result in an ambiguous match result.Enhancement
Clear any previous values in
IApiVersioningFeature.SelectionResult
each time the middleware is entered.Workaround
This problem can currently be worked around by explicitly reinitializing the
IApiVersioningFeature
instance with custom middleware as follows:The text was updated successfully, but these errors were encountered: