Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Simone Chiaretta 134 posts 541 karma points c-trib
    Feb 23, 2017 @ 16:31
    Simone Chiaretta
    1

    HealthCheckController doesn't work with WebAPI and Unity

    Still in the IoC world, after enabling ioc using with Unity for webapi I discovered that the HealthCheckController doesn't work.

    The reason is that it has 2 constructors, one parameterless and one with a service.

    So, only way to have it working is forcing it to use the parameterless controller.

    container.RegisterType<HealthCheckController>(new InjectionConstructor());
    

    I guess the reason is that all other controllers get their rependencies from the Services property of the UmbracoApiControllerBase class while the HealthCheckController, probably because it was a 3rd party plugin included into the core, manages dependency its own way.

    I created an issue: [U4-9562]

  • Shannon Deminick 1526 posts 5272 karma points MVP 3x
    Sep 12, 2017 @ 00:19
    Shannon Deminick
    100

    Have replied to that issue

    If you look into the code you can see the parameter that is required for the HealthCheckController https://github.com/umbraco/Umbraco-CMS/blob/dev-v7/src/Umbraco.Web/HealthCheck/HealthCheckController.cs#L21

    So you probably aren't registering a IHealthCheckResolver in your container.

    Using the parameterless constructor sort of voids the whole point of IoC ;)

  • Simone Chiaretta 134 posts 541 karma points c-trib
    Sep 19, 2017 @ 12:22
    Simone Chiaretta
    0

    I think the point here is: - as user of a framework, I shouldn't need to wire up dependencies for internals of the framework myself. I should only bother about my own dependencies. Maybe Umbraco should ship a small extension method for each of the main IoC container out there which wires up all the internals. Or come with a IoC container out of the box and then everyone using umbraco have to use that one.

  • Shannon Deminick 1526 posts 5272 karma points MVP 3x
    Sep 19, 2017 @ 23:21
    Shannon Deminick
    0

    Yup that's something that has been discussed and would be great to have. I know Claus has been talking about doing this for a while. Would be a super easy project to do and just have various Nuget packages to support it.

Please Sign in or register to post replies

Write your reply to:

Draft