You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, i am using windsor for resolving my dependencies, but i am now trying to run a web api in a console using OWIN in self-hosted mode.
Startup.cs in self-hosted solution
publicclassStartupSelfHosted:AbstractStartup{publicvoidConfiguration(IAppBuilderapp){varbuilder=newMobilePosConsoleInfrastructureBuilder();varcontainer=builder.Build();varconfig=newHttpConfiguration();builder.OnInitialize(config);app.UseWindsorDependencyResolverScope(config,container)//this is a hack found from a nuget.UseWebApi(config);container.AddFacility<AspNetWebApiFacility>(x =>x.UsingConfiguration(config).UsingSelfHosting());}}
in the startup.cs we set up the container and tell it use webapi.
Program.cs
publicstaticvoidMain(string[]args){stringbaseAddress="http://+:44316/";WebApp.Start<StartupSelfHosted>(url:baseAddress);System.Console.WriteLine("API is running at {0}",baseAddress);System.Console.ReadLine();}
The problem is that the Creationcontext from windsor is not the same as the OwinContext how can i resolve my clientkey if it comes from the self-hosted instance? I am clueless at the moment.
The text was updated successfully, but these errors were encountered:
ClumsyPenguin
changed the title
OWIN Self-hosted mode perwebrequest lifecycle
OWIN Self-hosted mode "perwebrequest" lifecycle
Oct 20, 2022
Hi, i am using windsor for resolving my dependencies, but i am now trying to run a web api in a console using OWIN in self-hosted mode.
Startup.cs in self-hosted solution
in the startup.cs we set up the container and tell it use webapi.
Program.cs
in program.cs we spin it up in self-hosted mode. as documented here: https://learn.microsoft.com/en-us/aspnet/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api
Normally we attach our httprequest to the creationcontext like this:
The thing is it will only work with dependencyresolvers inherited from
IDependencyResolver
and not withIHttpControllerActivator
as described here https://github.com/castleproject/Windsor/blob/master/docs/aspnetwebapi-facility.mdLater when we get a request we use SubDependencyResolvers to resolve e.g. clientkey to route the request to the correct database.
The problem is that the
Creationcontext
from windsor is not the same as theOwinContext
how can i resolve my clientkey if it comes from the self-hosted instance? I am clueless at the moment.The text was updated successfully, but these errors were encountered: