報錯信息:
Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches:
Api.Controllers.ProjectController.Paging (Api)
Api.Controllers.UserController.Paging (Api)
問題解析
請求匹配了多個端點,請求的后端接口路由重復了,檢查后發現以下兩個控制器的路由寫成一樣了
Api.Controllers.ProjectController.Paging (Api)
Api.Controllers.UserController.Paging (Api)
都寫成了
[Route("api/user")]
[ApiController]
解決方案
知道了問題所在,解決就簡單了,改一下Route就可以了
[Route("api/user")]
[Route("api/project")]
