The OWIN startup will create your WebAppHost
instance for you without using your container. In order to perform the startup with a class that has been injected, use the following code:
public class AppContext {
//[...]
public static void Start(string[] args) {
//[...]
_bootstrapper.Initialize(CreateKernel);
//Remember to dispose this or put around "using" construct.
WebApp.Start("uri", builder =>
{
var webHost = _bootstrapper.Kernel.Get<WebAppHost>();
webHost.Configuration(builder);
} );
}
//[...]
}
This will call Configuration
method in your WebAppHost
instance with your IAppSettings
injected.
PS: As a suggestion, I think you shouldn't use InRequestScope()
for your IAppSettings
binding in RegisterServices
. Use singleton, transient or custom scope for that. From my experience you wouldn't need any application settings that are bound to a request scope.