protected void Application_Start() { _hostContainer = OrchardStarter.CreateHostContainer(MvcSingletons); _host = _hostContainer.Resolve<IOrchardHost>(); _host.Initialize(); var route = RouteTable.Routes.MapRoute("foo", "hello-world", new { controller = "Home", action = "Index" }); route.RouteHandler = new HelloYetAgainHandler(); }
protected void Application_Start() { _hostContainer = OrchardStarter.CreateHostContainer(MvcSingletons); _host = _hostContainer.Resolve <IOrchardHost>(); _host.Initialize(); var route = RouteTable.Routes.MapRoute("foo", "hello-world", new { controller = "Home", action = "Index" }); route.RouteHandler = new HelloYetAgainHandler(); }
protected void Application_Start() { RegisterRoutes(RouteTable.Routes); _container = OrchardStarter.CreateHostContainer(MvcSingletons); _host = _container.Resolve<IOrchardHost>(); _host.Initialize(); // initialize shells to speed up the first dynamic query _host.BeginRequest(); _host.EndRequest(); }
protected void Application_Start() { RegisterRoutes(RouteTable.Routes); _container = OrchardStarter.CreateHostContainer(MvcSingletons); _host = _container.Resolve <IOrchardHost>(); _host.Initialize(); // initialize shells to speed up the first dynamic query _host.BeginRequest(); _host.EndRequest(); }
public async Task Invoke(HttpContext httpContext) { // Ensure all ShellContext are loaded and available. _orchardHost.Initialize(); var shellSetting = _runningShellTable.Match(httpContext); // Register the shell settings as a custom feature. httpContext.Features[typeof(ShellSettings)] = shellSetting; // We only serve the next request if the tenant has been resolved. if (shellSetting != null) { ShellContext shellContext = _orchardHost.GetOrCreateShellContext(shellSetting); using (var scope = shellContext.CreateServiceScope()) { httpContext.RequestServices = scope.ServiceProvider; if (!shellContext.IsActivated) { lock (shellSetting) { // The tenant gets activated here if (!shellContext.IsActivated) { var eventBus = scope.ServiceProvider.GetService <IEventBus>(); eventBus.NotifyAsync <IOrchardShellEvents>(x => x.ActivatingAsync()).Wait(); eventBus.NotifyAsync <IOrchardShellEvents>(x => x.ActivatedAsync()).Wait(); shellContext.IsActivated = true; } } } await _next.Invoke(httpContext); } using (var scope = shellContext.CreateServiceScope()) { var deferredTaskEngine = scope.ServiceProvider.GetService <IDeferredTaskEngine>(); if (deferredTaskEngine != null && deferredTaskEngine.HasPendingTasks) { var context = new DeferredTaskContext(scope.ServiceProvider); await deferredTaskEngine.ExecuteTasksAsync(context); } } } }
public async Task Invoke(HttpContext httpContext) { // Ensure all ShellContext are loaded and available. _orchardHost.Initialize(); var shellSetting = _runningShellTable.Match(httpContext); // Register the shell settings as a custom feature. httpContext.Features.Set(shellSetting); // We only serve the next request if the tenant has been resolved. if (shellSetting != null) { var shellContext = _orchardHost.GetOrCreateShellContext(shellSetting); using (var scope = shellContext.CreateServiceScope()) { httpContext.RequestServices = scope.ServiceProvider; if (!shellContext.IsActivated) { lock (shellContext) { // The tenant gets activated here if (!shellContext.IsActivated) { var tenantEvents = scope.ServiceProvider .GetServices <IModularTenantEvents>(); foreach (var tenantEvent in tenantEvents) { tenantEvent.ActivatingAsync().Wait(); } httpContext.Items["BuildPipeline"] = true; shellContext.IsActivated = true; foreach (var tenantEvent in tenantEvents) { tenantEvent.ActivatedAsync().Wait(); } } } } await _next.Invoke(httpContext); } } }
protected void Application_Start() { // This is temporary until MVC2 is officially released. // We want to avoid running against an outdated preview installed in the GAC CheckMvcVersion( new Version("2.0.50217.0")/*MVC2 RTM file version #*/, new Version("2.0.50129.0")/*MVC2 RC2 file version #*/, new Version("2.0.41211.0")/*MVC2 RC file version #*/); RegisterRoutes(RouteTable.Routes); _host = OrchardStarter.CreateHost(MvcSingletons); _host.Initialize(); //TODO: what's the failed initialization story - IoC failure in app start can leave you with a zombie appdomain }
protected void Application_Start() { // For information on handling configuration changes // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. RoleEnvironment.Changing += (sender, e) => { // If a configuration setting is changing if (e.Changes.Any(change => change is RoleEnvironmentConfigurationSettingChange)) { // Set e.Cancel to true to restart this role instance e.Cancel = true; } }; RegisterRoutes(RouteTable.Routes); _host = OrchardStarter.CreateHost(MvcSingletons); _host.Initialize(); }
public async Task Invoke(HttpContext httpContext) { var sw = Stopwatch.StartNew(); // Ensure all ShellContext are loaded and available. _orchardHost.Initialize(); var shellSetting = _runningShellTable.Match(httpContext); if (shellSetting != null) { ShellContext shellContext = _orchardHost.GetShellContext(shellSetting); httpContext.Items["ShellSettings"] = shellSetting; httpContext.ApplicationServices = shellContext.ServiceProvider; var scope = shellContext.ServiceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope(); using (scope) { httpContext.RequestServices = scope.ServiceProvider; if (!shellContext.IsActived) { var eventBus = scope.ServiceProvider.GetService <IEventBus>(); await eventBus.NotifyAsync <IOrchardShellEvents>(x => x.ActivatingAsync()); await eventBus.NotifyAsync <IOrchardShellEvents>(x => x.ActivatedAsync()); shellContext.IsActived = true; } await _next.Invoke(httpContext); } } else { _logger.LogError("Tenant not found"); throw new Exception("Tenant not found"); } _logger.LogVerbose("Request took {0}ms", sw.ElapsedMilliseconds); }
public async Task Invoke(HttpContext httpContext) { // Ensure all ShellContext are loaded and available. _orchardHost.Initialize(); var shellSetting = _runningShellTable.Match(httpContext); // We only serve the next request if the tenant has been resolved. if (shellSetting != null) { ShellContext shellContext = _orchardHost.GetShellContext(shellSetting); httpContext.ApplicationServices = shellContext.ServiceProvider; var scope = shellContext.ServiceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope(); using (scope) { httpContext.RequestServices = scope.ServiceProvider; if (!shellContext.IsActived) { IEventBus eventBus = null; lock (shellSetting) { // The tenant gets activated here if (!shellContext.IsActived) { eventBus = scope.ServiceProvider.GetService <IEventBus>(); } eventBus.NotifyAsync <IOrchardShellEvents>(x => x.ActivatingAsync()).Wait(); eventBus.NotifyAsync <IOrchardShellEvents>(x => x.ActivatedAsync()).Wait(); shellContext.IsActived = true; } } await _next.Invoke(httpContext); } } }
public void Configure(IApplicationBuilder builder, ILoggerFactory loggerFactory, IOrchardHost orchardHost) { builder.ConfigureWebHost(loggerFactory); orchardHost.Initialize(); }