示例#1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext dbContext, DataProtectionDbContext dpContext, ILogger <Startup> logger)
        {
            //logger?.LogDebug($"Config DB: {(Configuration as IConfigurationRoot).Providers.Select(p => { p.TryGet("ConnectionStrings:CWPConnection") ? })}")
            app.UseRequestLocalization();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStatusCodePagesWithRedirects("/error/{0}");

            if (env.IsProduction())
            {
                var forwardingOptions = new ForwardedHeadersOptions
                {
                    ForwardedHeaders = ForwardedHeaders.All
                };
                forwardingOptions.KnownNetworks.Clear(); //its loopback by default
                forwardingOptions.KnownProxies.Clear();
                app.UseForwardedHeaders(forwardingOptions);

                app.UseRewriter(new RewriteOptions().AddRedirectToHttpsPermanent());
                app.UseHsts(c => c.MaxAge(days: 365).IncludeSubdomains());

                app.UseIpRateLimiting();
            }

            app.UseRewriter(new RewriteOptions().AddRewrite("my/locales/(.*)/translation.json", "/locales/$1/translation.json", true));

            app.UseStaticFiles();

            app.UseNoCacheHttpHeaders();

            app.UseAuthentication();

            app.UseMvcWithDefaultRoute();

            app.UseResponseCompression();

            dbContext.Database.Migrate();
            dpContext.Database.Migrate();
        }
 public IndexModel(ILogger <IndexModel> logger, DataProtectionDbContext dataProtectionDbContext)
 {
     _logger  = logger;
     _context = dataProtectionDbContext;
 }
 public SqlXmlRepository(DataProtectionDbContext context)
 {
     DataProtectionDbContext = context;
 }