同时给GetTouristRouteById加head时,报500错误
来源:5-12 【应用】使用http的HEAD请求
慕运维3598789
2021-08-10
如果同时给GetTouristRouteById加head时,报500错误;只给GetTouristRoutes方法加时不报错
[HttpGet("{touristRouteId}")]
[HttpHead]
public IActionResult GetTouristRouteById(Guid touristRouteId)
错误内容是
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches:
FakeXiecheng.API.Controllers.TouristRoutesController.GetTouristRoutes (FakeXiecheng.API)
FakeXiecheng.API.Controllers.TouristRoutesController.GetTouristRouteById (FakeXiecheng.API)
at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(CandidateState[] candidateState)
at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ProcessFinalCandidates(HttpContext httpContext, CandidateState[] candidateState)
at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.Select(HttpContext httpContext, CandidateState[] candidateState)
at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.MatchAsync(HttpContext httpContext)
at Microsoft.AspNetCore.Routing.Matching.DataSourceDependentMatcher.MatchAsync(HttpContext httpContext)
at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
写回答
1回答
-
[HttpHead] 也加上路径试试
[HttpHead("{touristRouteId}")]112021-08-11
相似问题