Due to limitations on the server side I need to build a self hosting web service in .NET…
I’m currently looking at HttpSelfHostServer but I’m very un-cool with it’s magical construction of the controller, that seems to be, based on name alone and using only the default constructor.
For my tests I need to inject a value into the controller and using an IoC framework for this one usage where vanilla dependancy injection will suffice is over the top.
Is there any way I can do this with HttpSelfHostServer? or are there other, non-deprecated, self-hosting alternatives that give me control over my controller constructor calls.
The
HttpSelfHostConfigurationinstance that you need to provide to theHttpSelfHostServerconstructor inherits theDependencyResolverproperty from theHttpConfigurationclass. Hence, you can provide a custom dependency resolver as outlined here, for instance.