public override async Task Invoke(IOwinContext context) { if (context.Request.Path == "/random") { IOwinDependencyScope dependencyScope = context.GetRequestDependencyScope(); IRepository repository = dependencyScope.GetService(typeof(IRepository)) as IRepository; await context.Response.WriteAsync(repository.GetRandomText()); } else { await Next.Invoke(context); } }
public object GetService(Type serviceType) { return(_owinDependencyScope.GetService(serviceType)); }