Ejemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            var cachedResolver = new CachedTenantResolver <AppTenant>(
                new AppTenantResolver(),
                t => t.Hostnames,
                RequestIdentification.FromHostname()
                );

            //app.UseMultitenancy(new AppTenantResolver())
            app.UseMultitenancy(cachedResolver)
            .RedirectIfTenantNotFound <AppTenant>("https://github.com/saaskit/saaskit/wiki/Handling-unresolved-Tenants/", permanentRedirect: false);
        }
Ejemplo n.º 2
0
        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();

            // Add the following to the request pipeline only in development environment.
            if (env.IsDevelopment())
            {
                                #if DNX451
                app.UseBrowserLink();
                                #endif
                app.UseDeveloperExceptionPage(new ErrorPageOptions {
                    SourceCodeLineCount = 20
                });
                app.UseRuntimeInfoPage();                 // default path is /runtimeinfo
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // sends the request to the following path or controller action.
                app.UseExceptionHandler("/Home/Error");
            }

            // Add static files to the request pipeline. (eg css, js files)
            app.UseStaticFiles();


            var cachedResolver = new CachedTenantResolver <AppTenant>(
                new AppTenantResolver(),
                t => t.Hostnames,
                RequestIdentification.FromHostname()
                )
                                                                                                                                        // extra options around configuring CachedTenantResolver
                                 .SetMemoryCache(new MemoryCache(new MemoryCacheOptions()))
                                 .SetMemoryCacheEntryOptions(new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromHours(1))) // eg. sliding cache for 1 hour
            ;


            //app.UseMultitenancy(new AppTenantResolver())
            app.UseMultitenancy(cachedResolver)
            .RedirectIfTenantNotFound <AppTenant>("https://github.com/saaskit/saaskit/wiki/Handling-unresolved-Tenants/", permanentRedirect: false);


            // Add MVC and routes to the request pipeline.
            app.UseMvc(routes => AppStart.RouteConfig.Setup(routes));
        }