Injecting EPI IBlobFactory in service class using StructureMap?

Vote:
 

Hi, I have a .NET WebApi 2 controller class in my Episerver solution, that requires an (injected) service class, which I register via the prescribed EPI server StructureMap configuration.

This service class takes a constructor dependency on IBlobFactory, which - I suppose??? - gets added to the StructureMap container by EPI, or it will look it up when needed via EPI ServiceLocator or something?

Now I keep getting the exception: "Controller XXX does not have a parameterless constructor", when invoking the controller API method.

I did get it to work using a paramerless constructor and using Epi ServiceLocator to get the service, but that is not what I want...

It seems Structuremap does not inject dependencies in WebAPI controllers???

Any ideas on how to troubleshoot this issue are welcome...

#187944
Edited, Feb 07, 2018 8:26
Vote:
 

I found the problem, see https://world.episerver.com/blogs/Henrik-Fransas/Dates/2016/10/installing-webapi-and-enable-dependency-injection-for-it/ or https://www.epinova.no/en/blog/aspnet-web-api-in-episerver-cms-7-projects/

Since this is about DI in an API controller, we need a bit of additional setup to make this work, see links.

#187974
Feb 07, 2018 17:18
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.