// 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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseMvc(); }
public void Configure(IApplicationBuilder app) { app.Run(async context => { await context.Response.WriteAsync("ApplicationServicesEqual:" + (context.ApplicationServices == Services)); }); }
// 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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseIISPlatformHandler(); app.UseApplicationInsightsRequestTelemetry(); app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.Use(async (context, next) => { context.Response.Headers.Add("Access-Control-Allow-Origin", "*"); context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); context.Response.Headers.Add("Access-Control-Allow-Headers", new[] { "Content-Type, x-xsrf-token" }); if (context.Request.Method == "OPTIONS") { context.Response.StatusCode = 200; } else { await next(); } }); app.UseMvc(); SampleData.Initialize(app.ApplicationServices); }
public void Configure(IApplicationBuilder app) { app.UseMiddleware(typeof(MyMiddleware)); app.Run(async context => await context.Response.WriteAsync("---------- Done\r\n")); }
public void Configure(IApplicationBuilder app) { app.Run(async (context) => { await context.Response.WriteAsync("Hello World!"); }); }
public void Configure(IApplicationBuilder app) { app.UseIISPlatformHandler(); app.Run(async context => { var singleton1 = context.RequestServices.GetService<ISingleton>(); var singleton2 = context.RequestServices.GetService<ISingleton>(); var scoped1 = context.RequestServices.GetService<IScoped>(); var scoped2 = context.RequestServices.GetService<IScoped>(); var transient1 = context.RequestServices.GetService<ITransient>(); var transient2 = context.RequestServices.GetService<ITransient>(); var instance1 = context.RequestServices.GetService<IInstance>(); var instance2 = context.RequestServices.GetService<IInstance>(); await context.Response.WriteAsync( "<table>" + $"<tr><td>Singleton 1 and Singleton 2 are the same instance:</td><td> {object.ReferenceEquals(singleton1, singleton2)}</td></tr>" + $"<tr><td>Instance 1 and Instance 2 are the same instance:</td><td> {object.ReferenceEquals(instance1, instance2)}</td></tr>" + $"<tr><td>Scoped 1 and Scoped 2 are the same instance:</td><td> {object.ReferenceEquals(scoped1, scoped2)}</td></tr>" + $"<tr><td>Transient 1 and Transient 2 are the same instance:</td><td> {object.ReferenceEquals(transient1, transient2)}</td></tr>" + "</table><br><br><table>" + $"<tr><td>Singleton Id:</td><td> {singleton1.Id}</td></tr>" + $"<tr><td>Instance Id:</td><td> {instance1.Id}</td></tr>" + $"<tr><td>_instanceId:</td><td> {InstanceId}</td></tr>" + $"<tr><td>Scoped Id:</td><td> {scoped1.Id}</td></tr>" + $"<tr><td>Transient 1 Id:</td><td> {transient1.Id}</td></tr>" + $"<tr><td>Transient 2 Id:</td><td> {transient2.Id}</td></tr>" + "</table>"); }); }
// Configure is called after ConfigureServices is called. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.MinimumLevel = LogLevel.Information; loggerFactory.AddConsole(); // Configure the HTTP request pipeline. // Add the following to the request pipeline only in development environment. if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseErrorPage(ErrorPageOptions.ShowAll); } else { // Add Error handling middleware which catches all application specific errors and // send the request to the following path or controller action. app.UseErrorHandler("/Home/Error"); } // Add static files to the request pipeline. app.UseStaticFiles(); // Add MVC to the request pipeline. app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); // Uncomment the following line to add a route for porting Web API 2 controllers. // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}"); }); }
public void Configure(IApplicationBuilder app) { app.UseRequestLocalization(); // Add MVC to the request pipeline app.UseMvcWithDefaultRoute(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IConfigurationRoot configuration) { loggerFactory.AddConsole(configuration.GetSection("Logging")); loggerFactory.AddDebug(); // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859 try { using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>() .CreateScope()) { using (var db = serviceScope.ServiceProvider.GetService<ApplicationDbContext>()) { db.Database.EnsureCreated(); db.Database.Migrate(); } } } catch (Exception exception) { } app.UseCors("AllowAllOrigins"); // TODO: allow collection of allowed origins per client app.UseIISPlatformHandler(); app.UseStaticFiles(); app.UseMvc(); }
public static void Configure(IApplicationBuilder app) { app.UseMvc(routes => { routes.MapRoute("Dashboard", "app/{*catchall}", new { controller = "dashboard", action = "index" }); routes.MapRoute("Default", "{controller=home}/{action=index}/{id?}"); }); }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); app.UseIISPlatformHandler(); app.UseStaticFiles(); app.UseWelcomePage(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app) { app.UseIISPlatformHandler(); app.UseDefaultFiles(); app.UseStaticFiles(); }
// Configure is called after ConfigureServices is called. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { var builder = new ContainerBuilder(); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap = new Dictionary<string, string>(); //app.UseCookieAuthentication(options => //{ // options.AuthenticationScheme = "Temp"; // options.AutomaticAuthentication = false; //}, "external"); // Configure the HTTP request pipeline. //app.UseStaticFiles(); // Add the following route for porting Web API 2 controllers. // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}"); app.UseOAuthBearerAuthentication(options => { options.Authority = "https://localhost:44333/core"; //options.Authority = "https://karamaidentityserver.azurewebsites.net/core"; options.Audience = "https://karama.com/resources"; options.AutomaticAuthentication = true; }); app.UseMiddleware<RequiredScopesMiddleware>(new List<string> { "api3" }); app.UseCors("AllowSpecificOrigins"); // Add MVC to the request pipeline. app.UseMvc(); }
// Configure is called after ConfigureServices is called. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory) { // Configure the HTTP request pipeline. // Add the console logger. loggerfactory.AddConsole(minLevel: LogLevel.Verbose); // Add the following to the request pipeline only in development environment. if (env.IsEnvironment("Development")) { app.UseBrowserLink(); app.UseErrorPage(ErrorPageOptions.ShowAll); } else { // Add Error handling middleware which catches all application specific errors and // send the request to the following path or controller action. app.UseErrorHandler("/Home/Error"); } // Add static files to the request pipeline. app.UseStaticFiles(); // Add MVC to the request pipeline. app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); SampleData.Initialize(app.ApplicationServices); }
/// <summary> /// Configure default cookie settings for the application which are more secure by default. /// </summary> /// <param name="application">The application.</param> /// <param name="environment">The environment the application is running under. This can be Development, /// Staging or Production by default.</param> private static void ConfigureCookies( IApplicationBuilder application, IHostingEnvironment environment) { // In the Development environment, different ports are being used for HTTP and HTTPS. The // RequireHttpsAttribute expects to use the default ports 80 for HTTP and port 443 for HTTPS and simply // adds an 's' onto 'http'. Therefore, we don't require secure cookies in the development environment. SecurePolicy securePolicy; if (environment.IsDevelopment()) { // Ensure that the cookie can only be transported over the same scheme as the request. securePolicy = SecurePolicy.SameAsRequest; } else { // Ensure that the cookie can only be transported over HTTPS. securePolicy = SecurePolicy.Always; } application.UseCookiePolicy( new CookiePolicyOptions() { // Ensure that external script cannot access the cookie. HttpOnly = HttpOnlyPolicy.Always, Secure = securePolicy }); }
public void Configure(IApplicationBuilder app) { // Request pipeline app.UseWebSockets(); app.Use(HandleWebSocketsAsync); app.UseMvc(); // Initialization Task.Run(async () => { await InitializeDatabaseAsync(); await InitializeServiceBrokerAsync(app.ApplicationServices); }) .Wait(); // Background tasks Task.Run(async () => { await ProcessMessagesAsync(app.ApplicationServices); }); }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IApplicationEnvironment env) { var ksi = app.ServerFeatures.Get<IKestrelServerInformation>(); ksi.NoDelay = true; loggerFactory.AddConsole(LogLevel.Error); app.UseKestrelConnectionLogging(); app.Run(async context => { Console.WriteLine("{0} {1}{2}{3}", context.Request.Method, context.Request.PathBase, context.Request.Path, context.Request.QueryString); Console.WriteLine($"Method: {context.Request.Method}"); Console.WriteLine($"PathBase: {context.Request.PathBase}"); Console.WriteLine($"Path: {context.Request.Path}"); Console.WriteLine($"QueryString: {context.Request.QueryString}"); var connectionFeature = context.Connection; Console.WriteLine($"Peer: {connectionFeature.RemoteIpAddress?.ToString()} {connectionFeature.RemotePort}"); Console.WriteLine($"Sock: {connectionFeature.LocalIpAddress?.ToString()} {connectionFeature.LocalPort}"); var content = $"Hello world!{Environment.NewLine}Received '{Args}' from command line."; context.Response.ContentLength = content.Length; context.Response.ContentType = "text/plain"; await context.Response.WriteAsync(content); }); }
public void Configure(IApplicationBuilder app) { app.Run(context => { return context.Response.WriteAsync("Hello from ASP.NET Core!"); }); }
public void Configure(IApplicationBuilder app) { app.UseIISPlatformHandler(); app.UseMvc(routes => routes.MapRoute("default", "{controller}/{action}", new { controller = "home", action = "index" })); }
public void Configure(IApplicationBuilder app) { _validatorProvider.ServiceProvider = app.ApplicationServices; // Add MVC to the request pipeline. app.UseMvcWithDefaultRoute(); }
// Configure is called after ConfigureServices is called. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { // Add MVC to the request pipeline. app.UseMvc(); // Add the following route for porting Web API 2 controllers. // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}"); }
public void Configure(IApplicationBuilder app) { app.UseCultureReplacer(); app.UseErrorReporter(); app.UseMvc(routes => { routes.MapRoute( name: "isbn10", template: "book/{action}/{isbnNumber:IsbnDigitScheme10(true)}", defaults: new { controller = "InlineConstraints_Isbn10" }); routes.MapRoute("StoreId", "store/{action}/{id:guid?}", defaults: new { controller = "InlineConstraints_Store" }); routes.MapRoute("StoreLocation", "store/{action}/{location:minlength(3):maxlength(10)}", defaults: new { controller = "InlineConstraints_Store" }, constraints: new { location = new AlphaRouteConstraint() }); // Used by tests for the 'exists' constraint. routes.MapRoute("areaExists-area", "area-exists/{area:exists}/{controller=Home}/{action=Index}"); routes.MapRoute("areaExists", "area-exists/{controller=Home}/{action=Index}"); routes.MapRoute("areaWithoutExists-area", "area-withoutexists/{area}/{controller=Home}/{action=Index}"); routes.MapRoute("areaWithoutExists", "area-withoutexists/{controller=Home}/{action=Index}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { // The hosting environment can be found in a project's properties -> DEBUG or in launchSettings.json. if (_hostingEnvironment.IsDevelopment()) { // The exception page is only shown if the app is in development mode. app.UseDeveloperExceptionPage(); } // This middleware makes sure our app is correctly invoked by IIS. app.UseIISPlatformHandler(); // Add the MVC middleware service above first. Then use said middleware in this method. //app.UseMvc(routes => //{ // routes.MapRoute( // name: "default", // template: "{controller}/{action}/{id}", // defaults: new { controller = "Home", action = "Index" } // ); //}); app.UseMvcWithDefaultRoute(); // Always remember to add the static files middleware or the images from JavaScript or CSS // won't be served. app.UseStaticFiles(); // Whenever HTTP status codes like 404 arise, the below middleware will display them on the page. app.UseStatusCodePages(); }
// Configure is called after ConfigureServices is called. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.MinimumLevel = LogLevel.Information; // Add the following to the request pipeline only in development environment. if (env.IsDevelopment()) { app.UseBrowserLink(); //app.UseErrorPage(ErrorPageOptions.ShowAll); } else { // Add Error handling middleware which catches all application specific errors and // sends the request to the following path or controller action. //app.UseErrorHandler("/Home/Error"); } // Add static files to the request pipeline. app.UseStaticFiles(); // Add MVC to the request pipeline. app.UseMvc(routes => { }); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, BeaconsContextSeedData seeder) { app.UseStaticFiles(); app.UseDeveloperExceptionPage(); Mapper.Initialize(config => { config.CreateMap<Beacon, BeaconViewModel>().ReverseMap(); config.CreateMap<Log, LogViewModel>().ReverseMap(); }); app.UseIISPlatformHandler(); app.UseMvc(config => { config.MapRoute( name: "Default", template: "{controller}/{action}/{id?}", defaults: new { controller = "App", action ="Index"} ); }); seeder.EnsureSeedData(); }
public void Configure(IApplicationBuilder app) { app.Run(context => { return context.Response.WriteAsync("Hello PriyaLaksmi"); }); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); }); //app.UseEndpoints(endpoints => //{ // endpoints.MapGet("/", async context => // { // await context.Response.WriteAsync("Change world2!"); // }); //}); }
// 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(); } // 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", "Senai.Senatur.WebApi"); c.RoutePrefix = string.Empty; }); 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, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.ConfigureCustomExceptionMiddleware(); app.UseCors(builder=>builder.WithOrigins("http://localhost:4200").AllowAnyHeader()); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// 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(); } 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.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, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } 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.UseSpaStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } 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.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapBlazorHub(); endpoints.MapFallbackToPage("/_Host"); }); }
// 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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); 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.UseBrowserLink(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseIdentityServer(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); }
// 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(); } 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.UseAuthentication(); // app.UseHttpsRedirection(); app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"Resources")), RequestPath = new PathString("/Resources") }); app.UseMvc(); }
// 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(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { // To learn more about options for serving an Angular SPA from ASP.NET Core, // see https://go.microsoft.com/fwlink/?linkid=864501 spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseAngularCliServer(npmScript: "start"); } }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSession(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); }
/// <summary> /// 服务注册 /// </summary> /// <param name="app"></param> /// <param name="lifetime"></param> /// <param name="healthService"></param> /// <param name="consulService"></param> /// <returns></returns> public static IApplicationBuilder RegisterConsul(this IApplicationBuilder app, IApplicationLifetime lifetime, HealthModel healthService, ConsulModel consulService) { // 请求注册的 Consul 地址 var consulClient = new ConsulClient(x => x.Address = new Uri($"http://{consulService.Ip}:{consulService.Port}")); var httpCheck = new AgentServiceCheck() { // 服务启动多久后注册 DeregisterCriticalServiceAfter = TimeSpan.FromSeconds(5), // 健康检查时间间隔 Interval = TimeSpan.FromSeconds(10), // 健康检查地址 HTTP = $"http://{healthService.Ip}:{healthService.Port}/api/health/get", Timeout = TimeSpan.FromSeconds(5) }; // 注册 var registration = new AgentServiceRegistration() { Checks = new[] { httpCheck }, ID = healthService.Name + "_" + healthService.Port, Name = healthService.Name, Address = healthService.Ip, Port = healthService.Port, // 添加 urlprefix-/servicename 格式的 tag 标签,以便 Fabio 识别 Tags = new[] { $"urlprefix-/{healthService.Name}" } }; // 服务启动时注册,内部实现其实就是使用 Consul API 进行注册(HttpClient发起) consulClient.Agent.ServiceRegister(registration).Wait(); lifetime.ApplicationStopping.Register(() => { //服务停止时取消注册 consulClient.Agent.ServiceDeregister(registration.ID).Wait(); }); return(app); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, SeedingService seedingService) { var ptBR = new CultureInfo("pt-BR"); var localizationOptions = new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture(ptBR), SupportedCultures = new List<CultureInfo> { ptBR }, SupportedUICultures = new List<CultureInfo> { ptBR } }; app.UseRequestLocalization(localizationOptions); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); seedingService.Seed(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddFile("Logs/documentManagement-{Date}.txt"); app.UseLoggingMiddleware(); app.UseMiddleware<ExceptionMiddleware>(); if (env.IsDevelopment()) app.UseDeveloperExceptionPage(); else app.UseHsts(); app.UseCors("Policy"); app.UseHttpsRedirection(); app.UseMvc(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/document-management-v1/swagger.json", "Document Management API"); }); app.UseWelcomePage("/"); }
public void Configure(IApplicationBuilder app) { app.UseStaticFiles(); if (Wlniao.XServer.XStorage.Local.Using) { var root = Wlniao.IO.PathTool.Map(Wlniao.XServer.XStorage.Local.Path); if (!System.IO.Directory.Exists(root)) { System.IO.Directory.CreateDirectory(root); } app.UseStaticFiles(new StaticFileOptions() { FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(root) , RequestPath = new Microsoft.AspNetCore.Http.PathString() }); } app.UseMvc(routes => { routes.MapRoute("Path", "{controller}/{action}/{op}", new { action = "index", op = "" }); routes.MapRoute("Home", "{action}", new { controller = "app" }); routes.MapRoute("Root", "", new { controller = "app", action = "index" }); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { 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(); } // !!! V praxi povolit pre bezpecnost spojenia //app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// 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(); } else { app.UseHsts(); } app.UseCors(x => x .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); app.UseAuthentication(); app.UseSignalR(routes => { routes.MapHub <ScoresNotifyHub>("/scores"); }); app.UseMvc(); }
private void InitializeDatabase(IApplicationBuilder app) { using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope()) { serviceScope.ServiceProvider.GetRequiredService <PersistedGrantDbContext>().Database.Migrate(); var context = serviceScope.ServiceProvider.GetRequiredService <ConfigurationDbContext>(); context.Database.Migrate(); if (!context.Clients.Any()) { foreach (var client in IdentityServerConfig.Clients) { context.Clients.Add(client.ToEntity()); } context.SaveChanges(); } if (!context.IdentityResources.Any()) { foreach (var resource in IdentityServerConfig.IdentityResources) { context.IdentityResources.Add(resource.ToEntity()); } context.SaveChanges(); } if (!context.ApiResources.Any()) { foreach (var resource in IdentityServerConfig.ApiResources) { context.ApiResources.Add(resource.ToEntity()); } context.SaveChanges(); } } }
// 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) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseCors(MyAllowSpecificOrigins); app.UseHttpsRedirection(); app.UseMvc(); { app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); } loggerFactory.AddLog4Net(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1")); } app.UseHttpsRedirection(); app.UseRouting(); app.UseCors(x => x.AllowAnyHeader().AllowAnyMethod().WithOrigins("https://localhost:4200")); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// 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.UseRouting(); app.UseCors(builder => { builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); //app.UseHsts(); } app.UseStaticFiles(); app.UseCookiePolicy(); //app.UseHttpsRedirection(); app.UseRouting(); app.UseCookiePolicy(new CookiePolicyOptions { // workaround IdentityServer4 MinimumSameSitePolicy = SameSiteMode.Lax, }); app.UseAuthentication(); app.UseAuthorization(); app.UseCors("AllowAll"); app.UseEndpoints(endpoints => { endpoints.MapBlazorHub(); endpoints.MapFallbackToPage("/_Host"); }); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseCors("CorsPoilicy"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Books API V1"); }); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(builder => { builder.Run(async context => { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; var error = context.Features.Get <IExceptionHandlerFeature>(); if (error != null) { context.Response.AddApplicationError(error.Error.Message); await context.Response.WriteAsync(error.Error.Message); } }); }); } // app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider) { if (env.IsDevelopment()) { // TODO: Jaime, remember to disable this prior to go live!; app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSession(); app.UseRouting(); app.UseEndpoints(endpoints => { // Use this route options to route the application to the initial page desired. endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}" ); }); MigrateAndSeedData(serviceProvider); }
// 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(); } 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(); } // 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; }); app.UseMvc(); }
// 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(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSession(); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Login}/{id?}"); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { _logger.LogInformation($"Application running in HostingEnvironment: [{env.EnvironmentName}]"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error/Details"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseAuthentication(); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Account}/{action=Register}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); endpoints.MapHub <ChatHub>("/chathub"); endpoints.MapHub <VoteHube>("/votehube"); }); }
// 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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); var section = Configuration.GetSection("MongoDB"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseIISPlatformHandler(); app.UseCors("AllowAll"); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name:"api", template: "api/{controller}/{id?}" ); }); }
// 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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear()); app.UseStaticFiles(); app.UseIdentity(); // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715 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, ILoggerFactory loggerFactory) { SuperDataBase.Configure(env, app.ApplicationServices.GetService<IOptions<AppConfig>>()); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseIISPlatformHandler(); app.UseStaticFiles(); 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, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseWebMarkupMin(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }