Error: Multiple controller types were found that match the URL

2

When requesting a service from my App, give me this error:

  

Multiple controller types were found that match the URL. This can   happen if attribute routes on multiple controllers match the requested   URL. \ R \ n \ r \ nThe request has found the following matching controller   types:
  \ r \ nAuthorizerService.Controllers.NegarController \ r \ nAuthorizerService.Controllers.UpgradeController ",

But by the App I have this:

public async Task UpdateLiberacaoAsync(double id, string value, List<Liberacao> liber)
        {
            try
            {
                string url = $"http://www.inetglobal.com.br/autorizador/api/atualiza/{id}/{value}";
                var uri = new Uri(string.Format(url));
                var data = JsonConvert.SerializeObject(liber);
                var content = new StringContent(data, Encoding.UTF8, "application/json");
                HttpResponseMessage response = null;
                response = await client.PutAsync(uri, content);

                //if (!response.IsSuccessStatusCode)
                //{
                //    throw new Exception("Erro ao atualizar tabela de liberacao");
                //}
            }
            catch (Exception ex)
            {
                string er = ex.Message;
            }
        }

and in my service (AtorizadorService) see this: Controller

[EnableCors(origins: "*", headers: "*", methods: "*")]
    [RoutePrefix("api/Atualiza")]
    public class AtualizaController : ApiController
    {
        AutorizadorContext contexto = new AutorizadorContext();
        PedidoLiberacao liberacao = new PedidoLiberacao();

        [Route("{id}/{value}")]
        [AcceptVerbs("Put")]
        public void PutItensLiberacao(int id, string value)
        {
            liberacao.AtualizaLiberacao(id, value);
        }
    }

and my model service

[Route("{id}/{value}")]
        public void AtualizaLiberacao(int id, string value)
        {
            var lista = contexto.Liberacoes
                        .Where(l => l.IdOrcamento == id)
                        .ToList();

            lista.ForEach(f =>
            {
                f.FlagLiberacao = 1;
                f.AutorizouReceberAtrazado = value;
            });

            contexto.SaveChanges();

        }

The whole question is that I have another Deny call that is similarly passed, so parameters

[Route("{id}/{value}")]
        public void AtualizaNegarLiberacao(int id, string value)
        {
            var lista = contexto.Liberacoes
                        .Where(l => l.IdOrcamento == id)
                        .ToList();

            lista.ForEach(f =>
            {
                f.FlagLiberacao = 2;
                f.AutorizouReceberAtrazado = value;
            });

            contexto.SaveChanges();

        }

As I configure the routes for each service, it picks the right route.

    
asked by anonymous 08.11.2017 / 20:15

1 answer

1

Prefix one of the routes (or both) with a unique name.

For example:

[Route("Negar/{id}/{value}")]
public void AtualizaNegarLiberacao(int id, string value) { }
    
08.11.2017 / 20:19