"An error occurred when trying to
create a controller of type 'Prototype02Controller'. Make sure that the
controller has a parameterless public constructor."
Esto ocurre porque tienes un controlador en una web Api similar al siguiente:
[RoutePrefix("api/authentication")]
[ExceptionsHandler]
[AuthorizeAD(new string[] { "MasterRole" })]
public class AuthorizationController : ApiController
{
private readonly IAuthorizationService _authorizationService;
public AuthorizationController (AuthorizationService authorizationService)
{
Throw<ArgumentNullException>.WhenObject.IsNull(() => authorizationService);
_authorizationService = authorizationService;
}
[HttpGet]
[Route("getAuthenticatedUserAsync")]
[ExceptionsHandlerAttribute]
public async Task<HttpResponseMessage> GetAuthenticatedUserAsync()
{
dynamic user = await _authorizationService.GetAuthenticatedUserAsync();
if (user == null)
return null;
return Request.CreateResponse(HttpStatusCode.OK, new { user });
}
}
Estamos pasando un objeto en lugar de una abstracción por lo que el contenedor de inversión de dependencias no sabrá resolverlo y nos lanzará el error que hemos visto.
No hay comentarios:
Publicar un comentario