-1

i need to know why occurs the next situation and if exists a different solution:

Actually my Api has an error when with Swagger use in method controller a HttpDelete action and Route decoration:

[Route("delete/{id}"), HttpDelete("{id}")]
public async Task<IActionResult> DeleteSession(string id)
{   //... any code
}

enter image description here

Actually i only resolve the error when erase the Route decoration:

[HttpDelete("{id}")]
public async Task<IActionResult> DeleteSession(string id)
{ //... any code}

enter image description here

I want to know why occurs this error ?

Dr oscar
  • 359
  • 1
  • 4
  • 16

1 Answers1

0

Change this:

[Route("delete/{id}"), HttpDelete("{id}")]

To this:

[HttpDelete, Route("{id}")]

The way you were doing it defines the route twice... both times differently, which causes conflicts.

Andy
  • 12,859
  • 5
  • 41
  • 56