Hello,
currently, I'm learning Swagger, when I tried to create find by username ,I got the below error
[HttpGet]
[Route("{fullname:string}")]
public async Task<IActionResult> signIn([FromRoute] string fullname)
{
Console.WriteLine(fullname);
var woner = await dbContext.PetWoner.FindAsync(fullname);
if (woner == null)
{
return NotFound();
}
return Ok(woner);
}
InvalidOperationException: The constraint reference 'string' could not be resolved to a type. Register the constraint type with 'Microsoft.AspNetCore.Routing.RouteOptions.ConstraintMap'.
- Microsoft.AspNetCore.Routing.DefaultParameterPolicyFactory.Create(RoutePatternParameterPart parameter, string inlineText)
- Microsoft.AspNetCore.Routing.ParameterPolicyFactory.Create(RoutePatternParameterPart parameter, RoutePatternParameterPolicyReference reference)
- Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder+DfaBuilderWorker.AddParentsWithMatchingLiteralConstraints(List<DfaNode> nextParents, DfaNode parent, RoutePatternParameterPart parameterPart, IReadOnlyList<RoutePatternParameterPolicyReference> parameterPolicyReferences)
- Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder+DfaBuilderWorker.ProcessSegment(RouteEndpoint endpoint, List<DfaNode> parents, List<DfaNode> nextParents, RoutePatternPathSegment segment)
- Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder+DfaBuilderWorker.ProcessLevel(int depth)
- Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder.BuildDfaTree(bool includeLabel)
- Microsoft.AspNetCore.Routing.Matching.DfaMatcherBuilder.Build()
- Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher.CreateMatcher(IReadOnlyList<Endpoint> endpoints)
- Microsoft.AspNetCore.Routing.DataSourceDependentCache<T>.Initialize()
- System.Threading.LazyInitializer.EnsureInitializedCore<T>(ref T target, ref bool initialized, ref object syncLock, Func<T> valueFactory)
- System.Threading.LazyInitializer.EnsureInitialized<T>(ref T target, ref bool initialized, ref object syncLock, Func<T> valueFactory)
- Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher..ctor(EndpointDataSource dataSource, Lifetime lifetime, Func<MatcherBuilder> matcherBuilderFactory)
- Microsoft.AspNetCore.Routing.Matching.DfaMatcherFactory.CreateMatcher(EndpointDataSource dataSource)
- Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.InitializeCoreAsync()
- Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatcher|8_0(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task<Matcher> matcherTask)
- Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)