admin管理员组

文章数量:1122846

I'm implementing an OData controller in an ASP.NET Core project, and I've added a new HttpDelete endpoint to delete a person by their ID. However, when I send a DELETE request to the endpoint, I get the following error:

Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches: 

AirVinyl.Controllers.PeopleController.DeletePerson (AirVinyl)
AirVinyl.Controllers.PeopleController.DeletePerson (AirVinyl)
    [HttpDelete("odata/People({key})")]
    public async Task<IActionResult> DeletePerson (int key)
    {
        var currentPersion = await _airVinylDbContext.People.FirstOrDefaultAsync(c=>c.PersonId == key);
        if (currentPersion == null)
        {
            return NotFound(ModelState);
        }

        _airVinylDbContext.Remove(currentPersion);
        await _airVinylDbContext.SaveChangesAsync();

        return NoContent();
    }

I only have this one DeletePerson method in my PeopleController.

Confirmed that my PeopleController inherits from ODataController. Cleaned and rebuilt the solution to rule out stale builds.

本文标签: cOData The request matched multiple endpoints Matches when Delete requestStack Overflow