// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { //自动跳转到https app.UseHttpsRedirection(); } app.UseStaticFiles(); app.UseIdentityServer(); app.UseSession(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Account}/{action=Index}/{id?}"); }); }
public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseHandleRobots(); app.UseEnforceHttps(); app.UseExceptionHandler("/Error/ServerException"); app.UseStatusCodePagesWithReExecute("/Error/Code{0}"); } app.UseAiursoftSupportedCultures(); app.UseStaticFiles(); app.UseAuthentication(); app.UseLanguageSwitcher(); app.UseMvcWithDefaultRoute(); app.UseDocGenerator(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApplicationLifetime lifetime) { loggerFactory?.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); app.UseSwagger(c => { c.PreSerializeFilters.Add((swagger, httpReq) => swagger.Host = httpReq.Host.Value); }); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1 Docs"); }); }
public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { var pathBase = Configuration["PATH_BASE"]; if (!string.IsNullOrEmpty(pathBase)) { app.UsePathBase(pathBase); } app.UseStaticFiles(); app.UseCors("CorsPolicy"); app.UseMvcWithDefaultRoute(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "WalletRest.API V1"); c.OAuthClientId("walletrestswaggerui"); c.OAuthAppName("Wallet Rest Swagger UI"); }); }
public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } var defaultOptions = new DefaultFilesOptions(); defaultOptions.DefaultFileNames.Clear(); defaultOptions.DefaultFileNames.Add("index.html"); app.UseDefaultFiles(defaultOptions); app.UseStaticFiles(); Task.Run(async() => await Electron.WindowManager.CreateWindowAsync()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); app.UseAzureAppConfiguration(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true, ReactHotModuleReplacement = true }); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.MapWhen(x => !x.Request.Path.Value.StartsWith("/hub"), builder => { builder.UseMvc(routes => { routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" }); }); }); app.UseSignalR(options => { options.MapHub <RedditFeedHub>("/hub"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { //Initialize Data using (var scope = app.ApplicationServices.CreateScope()) { //Initialize database var services = scope.ServiceProvider; var dbContext = services.GetService <PetShop2019Context>(); var dbInitializer = services.GetService <IDbInitializer>(); dbInitializer.Initialize(dbContext); } if (env.IsDevelopment()) { //Initialize Data using (var scope = app.ApplicationServices.CreateScope()) { //Initialize database var services = scope.ServiceProvider; var dbContext = services.GetService <PetShop2019Context>(); var dbInitializer = services.GetService <IDbInitializer>(); dbContext.Database.EnsureDeleted(); dbContext.Database.EnsureCreated(); dbInitializer.Initialize(dbContext); } app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); // Enable CORS app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseFileServer(); //app.UseSignalR(routes => //{ // routes.MapHub<RemotePlayHub>("/remoteplay"); // routes.MapHub<RemotePlay2Hub>("/remoteplay2"); //}); app.UseAzureSignalR(routes => { routes.MapHub <RemotePlayHub>("/remoteplay"); routes.MapHub <RemotePlay2Hub>("/remoteplay2"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("Index.html"); app.UseHsts(); } app.Use(async(context, next) => { context.Response.OnStarting(() => { context.Response.Headers.Add("X-Powered-By", "GMJNOW"); return(Task.CompletedTask); }); await next.Invoke(); }); app.UseAuthentication(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvcWithDefaultRoute(); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); c.RoutePrefix = string.Empty; }); }
public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseExceptionHandler(new ExceptionHandlerOptions { ExceptionHandler = new ErrorHandlerMiddleware(env).Invoke }); app.UseMiddleware <AuthenticationMiddleware>(); app.UseHttpsRedirection(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseCors("Todos"); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" }); }); }
public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env, ApplContext context, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } var optionss = new RewriteOptions().AddRedirectToHttps(); app.UseRewriter(optionss); var locOptions = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >(); app.UseRequestLocalization(locOptions.Value); app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(options => { options.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); DbInitializer.Initialize(context); }
public DefaultExtensionsMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, IOptions <DefaultExtensionsOptions> options, ILoggerFactory loggerFactory) { if (hostingEnv == null) { throw new ArgumentNullException(nameof(hostingEnv)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } _next = next ?? throw new ArgumentNullException(nameof(next)); _fileProvider = hostingEnv.WebRootFileProvider; _options = options.Value; _logger = loggerFactory.CreateLogger <DefaultExtensionsMiddleware>(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider provider) { using (var serviceScope = app.ApplicationServices.CreateScope()) { var dbContext = serviceScope.ServiceProvider.GetRequiredService <WebAppDbContext>(); if (env.IsDevelopment()) { dbContext.Database.Migrate(); } new WebAppDbContextSeeder().SeedAsync(dbContext).GetAwaiter().GetResult(); } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { var context = serviceScope.ServiceProvider.GetService <WebApiDbContext>(); while (true) { try { context.Database.Migrate(); } catch (Exception) { continue; } break; } } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseCors(x => x .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseCors("CorsPolicy"); app.UseSignalR(routes => { routes.MapHub <Hubs.ToastHub>("/hubs/toast"); }); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors("CorsPolicy"); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Order App V1"); c.DocExpansion(DocExpansion.List); }); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env2, IWebHostEnvironment env, IServiceProvider serviceProvider, IRepository repository) { //MoviesController obj = new MoviesController(repository, env); app.UseHangfireServer(); app.UseHangfireDashboard(); //RecurringJob.AddOrUpdate(() => obj.MoviesToPdf(), Cron.Minutely); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); //RotativaConfiguration.Setup(env2, env2.WebRootPath+"\\Rotativa"); //CreateRoles(serviceProvider).Wait(); //RecurringJob.AddOrUpdate(() => obj.MoviesToPdf2(), Cron.Minutely); }
#pragma warning disable CA1822 // Mark members as static /// <summary> /// Configures this application. /// </summary> /// <remarks> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </remarks> /// <param name="app">The application.</param> /// <param name="env">The env.</param> public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) #pragma warning restore CA1822 // Mark members as static { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // static files app.UseDefaultFiles(); app.UseStaticFiles(); app.UseSignalR(routes => { routes.MapHub <ScraperHub>("/scraperHub"); }); app.UseMvc(routes => { routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}"); }); // apikey is stored as "secret" OmdbService.ApiKey = this.Configuration["omdbApiKey"] ?? throw new InvalidOperationException("The secret omdbApiKey is missing"); }
public Startup(Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); if (env.IsDevelopment()) { // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709 builder.AddUserSecrets("aspnet-aspCart.Web-b7b6c0c8-2794-41a1-ad6c-528772b97f8a"); } builder.AddEnvironmentVariables(); Configuration = builder.Build(); HostingEnvironment = env; MapperConfiguration = new MapperConfiguration(cfg => { cfg.AddProfile(new AutoMapperProfileConfiguration()); }); }
public Startup(Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { var builder = new ConfigurationBuilder(); if (env.IsDevelopment()) { builder .SetBasePath(env.ContentRootPath) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); } else { builder .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); } builder.AddEnvironmentVariables(); Configuration = builder.Build(); Common.AppConfig.Configuration = builder.Build(); AppJsonConfig.Configuration = builder.Build(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseStatusCodePagesWithReExecute("/Error/Status{0}"); app.UseExceptionHandler("/Error"); app.UseHsts(); } // Handle X-Fowarded-Proto to know Nginx is using HTTPS app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedFor, }); app.UseReact(config => { config .AddScript("~/Content/js/socialfeed.jsx") .SetReuseJavaScriptEngines(false); }); app.UseStaticFiles(); app.UseAuthentication(); app.UseSession(); app.UseMiniProfiler(); app.UseHangfireDashboard(options: new DashboardOptions { Authorization = new[] { new DashboardAuthorizationFilter() } }); // All real routes are defined using attributes. app.UseMvc(); CronScheduler.ScheduleCronjobs(); }
public ManageController( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, EmailSenderFactory emailSenderFactory, ILogger <ManageController> logger, UrlEncoder urlEncoder, BTCPayWalletProvider walletProvider, StoreRepository storeRepository, IWebHostEnvironment env, U2FService u2FService, BTCPayServerEnvironment btcPayServerEnvironment) { _userManager = userManager; _signInManager = signInManager; _EmailSenderFactory = emailSenderFactory; _logger = logger; _urlEncoder = urlEncoder; _Env = env; _u2FService = u2FService; _btcPayServerEnvironment = btcPayServerEnvironment; _StoreRepository = storeRepository; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "101mngr API V1"); }); app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()); app.UseAuthentication(); app.UseMvc(); app.UseSignalR(routes => { routes.MapHub <MatchHub>("/matches"); routes.MapHub <MatchRoomHub>("/rooms"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseAuthentication(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(endpoints => { endpoints.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSession(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); app.UseAuthentication(); app.UseHttpsRedirection(); app.UseMvc(routes => { routes.MapRoute("ExplictApi", "{controller}/{action}"); routes.MapRoute("TokenApi", "{controller=Manage}/{id}"); }); }
public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env) #endif { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); #if NETCOREAPP3_0 app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); #else app.UseMvc(); #endif }