The AmbiguousMatchException you encountered means that there are multiple endpoints in your code that match the incoming request. This can happen when you have multiple actions in a controller with the same name and same HTTP verb.

To resolve this issue, you need to make sure that each endpoint has a unique name or route. Here are a few possible solutions:

  1. Rename the conflicting action methods: Give each action method in your controller a unique name that reflects its purpose. For example, instead of having two Index methods, you can rename them to Index1 and Index2.

  2. Use attribute routing: Decorate your action methods with specific route attributes to differentiate them. By using [Route] attribute, you can specify unique routes for each action method. For example:

    [Route("api/controller/action1")]
    public IActionResult Action1()
    {
        // Action1 implementation
    }
    
    [Route("api/controller/action2")]
    public IActionResult Action2()
    {
        // Action2 implementation
    }
    
  3. Use HTTP verbs to differentiate: If the actions have the same name but serve different HTTP verbs, you can use the [HttpGet], [HttpPost], [HttpPut], etc. attributes to specify the appropriate HTTP verb for each action. For example:
    [HttpGet]
    public IActionResult Index()
    {
        // GET Index implementation
    }
    
    [HttpPost]
    public IActionResult Index()
    {
        // POST Index implementation
    }
    

By making these changes, you ensure that each endpoint has a unique identifier, and the AmbiguousMatchException should be resolved.