Copied to clipboard

Flag this post as spam?

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


  • Simon 686 posts 1059 karma points
    Jun 22, 2016 @ 08:13
    Simon
    0

    Simple Injector Framework - Registering WebApiControllers conflicting with CMS Apis (not working)

    Hi Guys,

    I am experiencing a situation where I have custom UmbracoApiControllers and in order to be able to inject Services as dependency injection, (I am using SimpleInjectorMVC) I have installed extension methods that basically register WebAPI Controllers

    container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

                container.RegisterWebApiControllers(configration, assemblies);
    
                container.RegisterMvcIntegratedFilterProvider();
    
                container.Verify();
                DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
                configration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
    

    My custom UmbracoAPIControllers are working fine when accessing them from my Frontend App (Angular 2) but when trying to access the umbraco CMS login, it does not allow me and throws an error, as seen below:

    enter image description here

    When I remove those two lines where I am registering WebApiControllers, everything works fine, except that I cannot inject services in my Api controllers.

    Does anyone has an idea what I can do to solve this issue please?

    Thank you

    Kind Regards

  • Simon 686 posts 1059 karma points
    Jun 22, 2016 @ 09:28
    Simon
    0

    Error:

    <Error>
    <Message>
    No HTTP resource was found that matches the request URI 'http://localhost:12646/umbraco/backoffice/UmbracoApi/Authentication/PostLogin'.
    </Message>
    <MessageDetail>
    No type was found that matches the controller named 'Authentication'.
    </MessageDetail>
    </Error>
    
  • Simon 686 posts 1059 karma points
    Jun 22, 2016 @ 12:59
    Simon
    0

    In my Global.asax,

    I have this:

    SimpleInjectorMvcInitializer.
                    InitializeSimpleInjectorMvc(IocHelpers.Container,
                    loadAllAssembliesManual(),
                    logMessage,
                    GlobalConfiguration.Configuration);
    

    How can I define not to initialize SimpleInjectorMVC for Umbraco CMS api controllers>?

    Appreciate any help.

    thank you.

  • Dan Lister 415 posts 1939 karma points c-trib
    Jan 10, 2017 @ 11:58
    Dan Lister
    0

    Hi Simon,

    Did you find a solution to this scenario?

    Thanks, Dan.

  • Alex Clavelle 13 posts 124 karma points
    Dec 19, 2017 @ 23:31
    Alex Clavelle
    0

    Has anyone solved this? I'm currently trying to integrate simpleinjector with my application and running into the same issue.

  • Alex Clavelle 13 posts 124 karma points
    Dec 19, 2017 @ 23:38
  • Stefan Kip 1577 posts 4012 karma points c-trib
    Jan 02, 2018 @ 13:27
    Stefan Kip
    1

    Looks like I solved it :-) Using this: container.RegisterWebApiControllers(GlobalConfiguration.Configuration);

    Instead of: container.RegisterWebApiControllers(GlobalConfiguration.Configuration, Assembly.GetExecutingAssembly());

Please Sign in or register to post replies

Write your reply to:

Draft