public static void UseMvc( this IPipelineBuilder @this, Action <IUseMvcBuilder> configureUseMvcBuilder = null) { var addMvcBuilder = @this.ServiceProvider.GetRequiredService <IAddMvcBuilder>(); var options = addMvcBuilder.MvcOptions; var useMvcBuilder = new UseMvcBuilder(@this.ServiceProvider); useMvcBuilder.Controllers = addMvcBuilder.Controllers; //Controllers settiongs. ControllersMiddlewareExtensions.InitUseMvcBuilder(useMvcBuilder); //Custom settings. //!Warning! Service bus will always return null values before we init MvcMiddleware. configureUseMvcBuilder?.Invoke(useMvcBuilder); var md = new MvcMiddleware(addMvcBuilder.MvcOptions, useMvcBuilder); //Add BotExt validator. if (options.ConfigureBotExtWithMvc) { @this.AddBotExtMvcGlobalValidator( options.BotExtOrder, md.SetGlobalSearchBag ); } @this.UseMiddleware(md); }