Error calling a method in ASP.NET Web API and Ninject

-1

I'm getting error when trying to call a method from a Web API.

Method declaration in ApiController

public class AcessoController : ApiController
{

    [HttpGet]
    public UsuarioModel ValidarUsuario(string login, string senha, string modoAutenticacao)
    {

    }

}

Consuming the API

HttpClient client = new HttpClient();
client.BaseAddress = new Uri(ConfigurationManager.AppSettings["UrlAPI"]);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

HttpResponseMessage response = new HttpResponseMessage();
response = await client.GetAsync(string.Format("api/Acesso/ValidarUsuario?login={0}&senha={1}&modoAutenticacao={2}", model.Login, model.Senha, (model.ModoAutenticacao == LoginViewModel.Dominio.Computecnica) ? "interno" : "externo"));

if (response.IsSuccessStatusCode) //esta retornando falso
{

}

Error:

  

Can not be null Parameter name: root

It seems to be a failure to construct the URL, since the execution of this method worked through UnitTest .

    
asked by anonymous 06.10.2016 / 20:33

1 answer

1

As spoken by comment , check that the package WebActivatorEx was installed together with Ninject.

The error:

  

Can not be null Parameter name: root

It is triggered by Ninject, not just the ASP.NET Web API.

    
06.10.2016 / 22:28