webapi報錯:
An unhandled exception occurred while processing the request.
AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied:
HcyDevServer.Controllers.UserInfoController.Get (HcyDevServer)
HcyDevServer.Controllers.UserInfoController.Get (HcyDevServer)
Microsoft.AspNetCore.Mvc.Internal.ActionSelector.SelectBestCandidate(RouteContext context, IReadOnlyList<ActionDescriptor> candidates)
- Stack
- Query
- Headers
-
AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied: HcyDevServer.Controllers.UserInfoController.Get (HcyDevServer) HcyDevServer.Controllers.UserInfoController.Get (HcyDevServer)
-
Microsoft.AspNetCore.Mvc.Internal.ActionSelector.SelectBestCandidate(RouteContext context, IReadOnlyList<ActionDescriptor> candidates)
-
Microsoft.AspNetCore.Mvc.Internal.MvcAttributeRouteHandler.RouteAsync(RouteContext context)
-
Microsoft.AspNetCore.Routing.Tree.TreeRouter.RouteAsync(RouteContext context)
-
Microsoft.AspNetCore.Routing.RouteCollection.RouteAsync(RouteContext context)
-
Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
-
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
-
解決辦法,指定action就可以了。
//[Route("api/[controller]")]
[Route("api/[controller]/[action]/")]
訪問比如:https://localhost:44366/api/userinfo/FindUser?username=eee&sex=1
這次就能訪問了。