I have an IFoo
instance which I need to use as per request instance. Here is how my startup class look like:
public void Configuration(IAppBuilder app)
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute("DefaultHttpRoute", "api/{controller}");
app.Use<RandomTextMiddleware>()
.UseWebApi(config);
}
RandomTextMiddleware
is a pass-through middleware and I need an instance of IFoo
implementation there. I also need an instance of IFoo
implementation inside my Web API pipeline.
How would you solve this problem so that I have the same instance of IFoo
implementation inside the RandomTextMiddleware
and the Web API pipeline per HTTP request?
If we keep OWIN clean in this way, then I believe there is a need for an 'interoperable pipeline' that can provide the ability for adding middleware-like components that work within the context of an app, but independantly of framework. This is something that Superscribe aims to provide.