// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IOptions <AegisOptions> aegisOptions, IOptions <ServerOptions> serverOptions, IOptions <RequestLocalizationOptions> l10nOptions, DbLoggerProvider dbLogProvider) { if (_environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/sys/error"); } // Https Rewriter if (serverOptions.Value.UseHttpsRewriter) { var rewriteOptions = new RewriteOptions().AddRedirectToHttps(); app.UseRewriter(rewriteOptions); } // logging //_loggerFactory.AddProvider(dbLogProvider); _loggerFactory.AddConsole(_configuration.GetSection("Logging")); _loggerFactory.AddDebug(LogLevel.Debug); // app components app.UseSession(); app.UseMultitenancy <SiteContext>(); app.UseRequestLocalization(l10nOptions.Value); app.UseStaticFiles(); app.UseKendo(_environment); // cookie policy app.UseCookiePolicy(new CookiePolicyOptions { HttpOnly = HttpOnlyPolicy.None, Secure = CookieSecurePolicy.SameAsRequest }); // openid security app.UsePerTenant <SiteContext>((ctx, builder) => { builder.UseAegisOidc(aegisOptions, ctx.Tenant); }); // Application migrations app.RunAppMigrations(); //validate Client Active Status //app.RunActiveClientValidation(); // configure plugins _plugins.Configure(app); // configure MVC convention based routes app.UseMvc(routes => { #region Ajax / Api Services //TODO: Cleanup Widget routes. Move behind sys/ routes.MapRoute( name: "admin", template: "admin/{controller=Dashboard}/{action=Index}/{id?}", defaults: new { area = "Admin" } ); //TODO: route behind "sys/" routes.MapRoute( name: "Ajax Components", template: "components/{type}/{cid?}", defaults: new { controller = "Components", action = "Render" } ); routes.MapRoute( name: "content", template: "sys/content/{action}", defaults: new { controller = "Content" } ); #endregion #region Back Office Routes //TODO: use "sys/account" instead routes.MapRoute( name: "User Account", template: "sys/account/{action=profile}", defaults: new { area = "Admin", controller = "Account" } ); routes.MapRoute( name: "Corp Admin", template: "sys/corp/admin/{action=dashboard}", defaults: new { area = "Admin", controller = "CorpAdmin" } ); routes.MapRoute( name: "Client Admin", template: "sys/clients/{tenant}/admin/{action=dashboard}", defaults: new { area = "Admin", controller = "ClientAdmin" } ); routes.MapRoute( name: "Site Admin", template: "sys/sites/{tenant}/admin/{action=dashboard}", defaults: new { area = "Admin", controller = "SiteAdmin" } ); #endregion #region CMS Front End Routes routes.MapRoute( name: "Notify Me", template: "sys/notifyme/{action}", defaults: new { area = "Public", controller = "NotifyMeSignUp" } ); //routes.MapRoute( // name: "Site Alerts", // template: "sys/sitealerts/{action}", // defaults: new { area = "Public", controller = "SiteAlerts" } //); routes.MapRoute( name: "Search", template: "sys/search/{action}", defaults: new { area = "Public", controller = "Search" } ); routes.MapRoute( name: "Page Provider by Route", template: "{*route}", defaults: new { area = "Public", controller = "SitePage", action = "RenderRoute", route = "/" } ); #endregion }); // enable jobs app.UseJobs(); //----------------------------------------------------------- // TODO: These need to go away - Convert to IAppMigrations // ----------------------------------------------------------- app.RunStartupActions(); _plugins.RunStartupActions(app); }