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
I am trying to set order of Routes (with same path : api/v1/users ) defined in minimal APIs using app.Map(..) by giving Order to both definitions so that at a time only one is used
i am using followinfg code:
var endPt1 = new RouteEndpointBuilder(emptyDelegate, RoutePatternFactory.Parse("/api/v1/users"), 1);
app.Map(endPt1.RoutePattern, getUser1);
var endPt2 = new RouteEndpointBuilder(emptyDelegate, RoutePatternFactory.Parse("/api/v1/users"),2);
app.Map(endPt2.RoutePattern, getUser2);
In RoutePattern.InboundPrecedence the value is same in both endPt1, endPt2.
Is this a bug?
How can i set order correctly so that even in minimal APIs ... at a time with same path, only one route is called with lower order Precedence?
Expected Behavior
Route configured with lower precedence should be executed
in code below ..
var endPt1 = new RouteEndpointBuilder(emptyDelegate, RoutePatternFactory.Parse("/api/v1/users"), 1);
app.Map(endPt1.RoutePattern, getUser1);
var endPt2 = new RouteEndpointBuilder(emptyDelegate, RoutePatternFactory.Parse("/api/v1/users"),2);
app.Map(endPt2.RoutePattern, getUser2);
endPt1 should have been executed, but i am getting exception
You're not really using the builder here though, just the pattern literal. One way to go about this is to configure the EndpointBuilder via a convention:
You're not really using the builder here though, just the pattern literal. One way to go about this is to configure the EndpointBuilder via a convention:
Is there an existing issue for this?
Describe the bug
I am trying to set order of Routes (with same path :
api/v1/users
) defined in minimal APIs using app.Map(..) by giving Order to both definitions so that at a time only one is usedi am using followinfg code:
In
RoutePattern.InboundPrecedence
the value is same in both endPt1, endPt2.Is this a bug?
How can i set order correctly so that even in minimal APIs ... at a time with same path, only one route is called with lower order Precedence?
Expected Behavior
Route configured with lower precedence should be executed
in code below ..
endPt1 should have been executed, but i am getting exception
Steps To Reproduce
github link
Code path: \AppNet6\Modules
Exceptions (if any)
An unhandled exception occurred while processing the request.
AmbiguousMatchException: The request matched multiple endpoints. Matches:
/api/v1/users => getUser1
/api/v1/users => getUser2
Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(CandidateState[] candidateState)
.NET Version
6.0.101
Anything else?
No response
The text was updated successfully, but these errors were encountered: