How do I get an instance of IAppBuilder elsewhere in my ASP.NET MVC 5.2.3 application?
问题 I need to build an Owin middle-ware object but not from within the Startup class. I need to build it from within anywhere else in my code, so I need a reference to the AppBuilder instance of the application. Is there a way to get that from anywhere else? 回答1: You could simply inject AppBuilder itself to OwinContext . But since Owin context only supports IDisposable object, wrap it in IDisposable object and register it. public class AppBuilderProvider : IDisposable { private IAppBuilder _app;