Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
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.
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...