public FileSystemAccountStore( ILogger logger, IOptions <LetsEncryptOptions> options, IHostEnvironment env) : this(new DirectoryInfo(AppContext.BaseDirectory), logger, options, env) { }
public DeveloperCertLoader( IHostEnvironment environment, ILogger <DeveloperCertLoader> logger) { _environment = environment; _logger = logger; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } using (var scope = app.ApplicationServices.CreateScope()) using (var sampleDbContext = scope.ServiceProvider.GetService <SampleDbContext>()) { sampleDbContext.Database.EnsureCreated(); } #if NETCOREAPP2_1 app.UseMvcWithDefaultRoute(); #else app.UseRouting(); app.UseEndpoints(endpoint => { endpoint.MapDefaultControllerRoute(); endpoint.MapGrpcService <GreeterImpl>(); }); #endif }
public Startup(Microsoft.Extensions.Hosting.IHostingEnvironment env) { IConfigurationRoot appSettings = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath).AddJsonFile("appsettings.json").Build(); Configuration = appSettings; }
public static IHostBuilder CreateHostBuilder(string[] args) { IHostingEnvironment hostingEnvironment = null; return (Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder .UseContentRoot(Directory.GetCurrentDirectory()) .ConfigureServices( services => { hostingEnvironment = services .Where(x => x.ServiceType == typeof(IHostingEnvironment)) .Select(x => (IHostingEnvironment)x.ImplementationInstance) .First(); }) .UseKestrel(options => { var config = new ConfigurationBuilder() .AddJsonFile($"appsettings.{hostingEnvironment.EnvironmentName}.json", optional: false) .Build(); options.Listen(IPAddress.Loopback, config.GetValue <int>("Host:Port")); }) .UseStartup <Startup>(); })); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IAmqpService amqpService, IApplicationLifetime applicationLifetime) { if (_hostingEnvironment.IsDevelopment() || _hostingEnvironment.IsEnvironment("DevelopmentServer")) { app.UseDeveloperExceptionPage(); } loggerFactory.AddConsole(Configuration.GetSection("Logging")); //loggerFactory.AddDebug(); loggerFactory.AddLog4Net(Path.Combine(ContentRoot, "config/log4net.config")); app.UseMvc(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "SmartDevicesGatewayAPI"); }); //using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope()) //{ // var dbContext = serviceScope.ServiceProvider.GetService<SmartdevicesGatewayDBContext>(); // var dbNewlyCreated = dbContext.Database.EnsureCreated(); //} applicationLifetime.ApplicationStarted.Register(OnStarted); applicationLifetime.ApplicationStopping.Register(OnShutdown); _app = app; }
private static bool CheckHostingEnvironmentIsProductionOrStagingOrDevelopment( Microsoft.Extensions.Hosting.IHostingEnvironment hostingEnvironment) { return(hostingEnvironment.IsProduction() || hostingEnvironment.IsStaging() || hostingEnvironment.IsDevelopment()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.Extensions.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseSignalR(configure => { configure.MapHub <FollowerHub>("/followerstream"); }); 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, Microsoft.Extensions.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors("ElektronskaOglasnaTabla"); app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"Resources")), RequestPath = new PathString("/Resources") }); app.UseSignalR(options => { options.MapHub <AnnouncementHub>("/AnnouncementHub"); options.MapHub <MessageHub>("/MessageHub"); }); //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.Extensions.Hosting.IHostingEnvironment env, IConfiguration config) { // Cheer 100 Crazy240sx 12/18/2018 if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); } app.UseHsts(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSignalR(configure => { configure.MapHub <FollowerHub>("/followerstream"); configure.MapHub <GithubyMcGithubFace>("/github"); configure.MapHub <AttentionHub>("/attentionhub"); }); 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(); } // 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"); }); app.UseRouting(); app.UseCors("all"); 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) { var hub = app.ApplicationServices.GetService <IHubContext <LogHub> >(); Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.SignalRLogger <LogHub>(hub) .WriteTo.Console() .CreateLogger(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseSignalR(config => { config.MapHub <ChatHub>("/chat"); config.MapHub <LogHub>("/log"); }); app.Use(async(context, next) => { await context.Response.WriteAsync("Hello World!"); await next(); }); // app.Run(async context => // { // await context.Response.WriteAsync("Hello World!"); // }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.Extensions.Hosting.IHostingEnvironment 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); } }); }); // 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.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); 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, IHostingEnvironment env, ILoggerFactory loggerFactory) { 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(); } loggerFactory.AddSerilog(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
public CertificateFactory( TermsOfServiceChecker tosChecker, IOptions <LetsEncryptOptions> options, IHttpChallengeResponseStore challengeStore, IAccountStore?accountRepository, ILogger logger, IHostEnvironment env, IHostApplicationLifetime appLifetime, TlsAlpnChallengeResponder tlsAlpnChallengeResponder) { _tosChecker = tosChecker; _options = options; _challengeStore = challengeStore; _logger = logger; _tlsAlpnChallengeResponder = tlsAlpnChallengeResponder; _appStarted = new TaskCompletionSource <object?>(); appLifetime.ApplicationStarted.Register(() => _appStarted.TrySetResult(null)); if (appLifetime.ApplicationStarted.IsCancellationRequested) { _appStarted.TrySetResult(null); } _accountRepository = accountRepository ?? new FileSystemAccountStore(logger, options, env); AcmeServer = _options.Value.GetAcmeServer(env); }
public AcmeCertificateLoader( CertificateSelector selector, IHttpChallengeResponseStore challengeStore, IOptions <LetsEncryptOptions> options, ILogger <AcmeCertificateLoader> logger, IHostEnvironment hostEnvironment, IServer server, IConfiguration config, TermsOfServiceChecker tosChecker, IEnumerable <ICertificateRepository> certificateRepositories, IClock clock, IHostApplicationLifetime applicationLifetime, TlsAlpnChallengeResponder tlsAlpnChallengeResponder, IAccountStore?accountStore = default) { _selector = selector; _challengeStore = challengeStore; _accountStore = accountStore; _options = options; _logger = logger; _hostEnvironment = hostEnvironment; _server = server; _config = config; _tosChecker = tosChecker; _certificateRepositories = certificateRepositories; _clock = clock; _applicationLifetime = applicationLifetime; _tlsAlpnChallengeResponder = tlsAlpnChallengeResponder; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.Extensions.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); //app.Run(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public void Configure(IApplicationBuilder app, Microsoft.Extensions.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true, ReactHotModuleReplacement = true }); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMetricServer(); 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 Startup(IConfiguration configuration, Microsoft.Extensions.Hosting.IHostingEnvironment hostingEnvironment) { var configBuilder = new ConfigurationBuilder() .SetBasePath(hostingEnvironment.ContentRootPath) .AddJsonFile($"appsettings.{hostingEnvironment.EnvironmentName}.json"); Configuration = configBuilder.Build(); }
public Startup(Microsoft.Extensions.Hosting.IHostingEnvironment env) { // we injected appsetting file var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); ApplicationSetup = builder.Build(); }
public Startup(IConfiguration configuration, IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); ConfigurationSetUp = builder.Build(); Configuration = configuration; }
public Startup(Microsoft.Extensions.Hosting.IHostingEnvironment env) { var builder = new ConfigurationBuilder().SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{env.EnvironmentName}.json") .AddEnvironmentVariables(); Configuration = builder.Build(); }
public Startup(Microsoft.Extensions.Hosting.IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile($"appsettings.{System.Environment.GetEnvironmentVariable("myCustomParam")}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); }
public Startup(IConfiguration configuration, ILoggerFactory loggerFactory, IHostingEnvironment hostingEnvironment) { Configuration = configuration; _loggerFactory = loggerFactory; _logger = loggerFactory.CreateLogger <Startup>(); _hostingEnvironment = hostingEnvironment; ContentRoot = Configuration["contentRoot"] ?? "."; }
public Startup(IHostingEnvironment env) { var cfgBuilder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{env.EnvironmentName}.json"); Configuration = cfgBuilder.Build(); }
public DeveloperCertLoader( IHostEnvironment environment, CertificateSelector certSelector, ILogger <DeveloperCertLoader> logger) { _environment = environment; _certSelector = certSelector; _logger = logger; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, Microsoft.Extensions.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); }
/// <summary> /// The uri to the server that implements the ACME protocol for certificate generation. /// </summary> internal static Uri GetAcmeServer(LetsEncryptOptions options, IHostEnvironment env) { var useStaging = options.UseStagingServerExplicitlySet ? options.UseStagingServer : env.IsDevelopment(); return(useStaging ? WellKnownServers.LetsEncryptStagingV2 : WellKnownServers.LetsEncryptV2); }
public void Configure(IApplicationBuilder app, Microsoft.Extensions.Hosting.IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseOwin(x => x.UseNancy()); }
/// <summary> /// Constructor /// </summary> public Startup(IConfiguration configuration, Microsoft.Extensions.Hosting.IHostingEnvironment environment) { Configuration = configuration; Metrics.DefaultRegistry.SetStaticLabels(new Dictionary <string, string> { { "environment", environment.EnvironmentName }, { "hostname", Environment.MachineName }, { "application", "PeerMeeting" } }); }