Closed paulsaxton closed 5 years ago
Is this an OWIN application? If so, you need to use the HttpConfiguration
instance created in the Startup
class and not the GlobalConfiguration
. See the OWIN specific steps in the documentation.
https://autofac.readthedocs.io/en/latest/integration/webapi.html#owin-integration
This appears to have been double-posted to StackOverflow. We can continue troubleshooting/follow up there to avoid double efforts.
I am struggling to get AutoFac to work with WebApi2 controllers
I always get an error that there is no parameterless constructor
I have been through loads of posts on this online and I cant see that I have missed anything
When I look at my container after it has been built I can see that it does contain my controller
I am using TopShelf
In my assembly module I have the line which I have verified is being called
In my class that is started by TopShelf I have -
My Startup class is -
I think the key is the place that I set the dependency resolver but it doesnt seem to make any difference where I call this, i.e. before or after I start the API
My controller is:
Can anyone see what I have done wrong please?
Paul