0

I have looked at quite a few articles here, but none of them seem to be suitable for my case. If it helps or pertains to the issue, I am using ninjectMVC for dependency injection.

I have an Angular $http as such:

$http({
    method: 'POST',
    url: '/Lookup/GetChangeOptions/'
}).success(function (data) {
    console.log(data);
    var test = data;
    //$scope.changeOptions = data;
}).error(function (jqXhr, textStatus, errorThrown) {
    console.log(errorThrown);
});

Which calls my controller:

public class LookupController : Controller
{
    private readonly ILookupService _lookupService;

    public LookupController(ILookupService lookupService)
    {
        _lookupService = lookupService;
    }

    public JsonResult GetOtherIssues()
    {
        var otherIssues = _lookupService.GetOtherIssues();

        return Json(otherIssues);
    }

    public JsonResult GetChangeOptions()
    {
        var changeOptions = _lookupService.GetChangeOptions();

        return Json(changeOptions);
    }
}

The call is giving me the error:

"System.MissingMethodException: No parameterless constructor defined for this object."

I am not sure what is causing the issue.. I have used similar structures in the past without any problems. Please let me know if I need to put the code of my service, but when I debug the call.. my break point in the controller is not even hit.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
ArjaaAine
  • 886
  • 5
  • 14
  • 27
  • 2
    is your ioc container properly registered? – Daniel A. White Jun 17 '14 at 00:28
  • 1
    http://stackoverflow.com/questions/1355464/asp-net-mvc-no-parameterless-constructor-defined-for-this-object?rq=1 – Daniel A. White Jun 17 '14 at 00:28
  • That was it, such a stupid mistake. Thanks a lot boss. Because of a previous issue, i had excluded the IOC initialization from the project and forgot to add it back again. Could you post this in a new post, so I can mark it as the answer :-) – ArjaaAine Jun 17 '14 at 00:41

1 Answers1

1

Ensure your IoC container is still resolving.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445