title: Avoiding "Request matched multiple actions resulting in ambiguity" error in ASP.Net Core
body: <p>I am trying to do something <em>simple</em> and <em>trivial</em> - or at least I thought.</p>
  
  <p>I am trying to write a base class that can be inherited by each micro-service project I spin up.  The point of this base class is to test connectivity from HTTP all the way through to SQL.  It is NOT enabled in PROD.</p>
  
  <p>This is one of the (simpler) base classes:</p>
  
  <pre><code>public class DevTestControllerBase: ApiControllerBase
  {
      public DevTestControllerBase(IHostingEnvironment env, IConfiguration configuration = null, IMediator mediator = null) : base(env, configuration, mediator)
      {
      }
  
  
      [HttpGet]
      public IActionResult Get()
      {
          var response = Mediator.Send(new QueryGet());
          return Ok(response.Result);
      }
  
      [HttpGet("{id}", Name = "Get")]
      public IActionResult Get(Guid id)
      {
          var response = Mediator.Send(new QueryGetById(id));
          return Ok(response.Result);
      }
  
      [HttpPost]
      public async Task&lt;IActionResult&gt; Post([FromBody]DevTestModelBinding value)
      {
          if (!ModelState.IsValid)
              return BadRequest(ModelState);
  
          var response = await Mediator.Send(new CommandPost(value));
          return Created("Get", new { id = response });
      }
  
      [HttpPut("{id}")]
      public IActionResult Put(Guid id, [FromBody]DevTestModelBinding value)
      {
          if (!ModelState.IsValid)
              return BadRequest(ModelState);
  
          Mediator.Send(new CommandPut(id, value));
          return Ok();
      }
  
      [HttpDelete("{id}")]
      public IActionResult Delete(Guid id)
      {
          Mediator.Send(new CommandDelete(id));
          return Ok();
      }
  }
  </code></pre>
  
  <p>I was hoping to use it as:</p>
  
  <pre><code>[Produces("application/json")]
  [Route("api/DevTest")]
  public class DevTestController : DevTestControllerBase
  {
      public DevTestController(IHostingEnvironment env, IConfiguration configuration, IMediator mediator) : base(env, configuration, mediator) { }
  }
  </code></pre>
  
  <p>Unfortunately, it produces this error instead:</p>
  
  <blockquote>
    <p>AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied:</p>
    
    <p>MyNamespace.Providers.WebApi.Features.DevTest.DevTestController.Get
    (MyNamespace.Providers.WebApi)
    MyNamespace.Infrastructure.Web.Controllers.DevTestControllerBase.Get
    (MyNamespace.Infrastructure.Web)</p>
  </blockquote>
  
  <p>And since I wanted to use Swagger, I am also getting this error when trying to hit the Swagger endpoint:</p>
  
  <blockquote>
    <p>An unhandled exception has occurred while executing the request
    System.NotSupportedException: Ambiguous HTTP method for action -
    MyNamespace.Providers.WebApi.Features.DevTest.DevTestController.Get
    (MyNamespace.Providers.WebApi). Actions require an explicit HttpMethod
    binding for Swagger 2.0</p>
  </blockquote>