首页 > 其他分享 >An unhandled exception occurred while processing the request 解决办法

An unhandled exception occurred while processing the request 解决办法

时间:2022-10-29 12:40:24浏览次数:65  
标签:RouteContext exception AspNetCore processing request actions HcyDevServer contex


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 
  • Cookies 
  • 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​​

这次就能访问了。

标签:RouteContext,exception,AspNetCore,processing,request,actions,HcyDevServer,contex
From: https://blog.51cto.com/51souta/5806006

相关文章