public DthTests() { _loggerFactory = new LoggerFactory(); var testVerbose = Environment.GetEnvironmentVariable("DOTNET_TEST_VERBOSE"); if (testVerbose == "2") { _loggerFactory.AddConsole(LogLevel.Trace); } else if (testVerbose == "1") { _loggerFactory.AddConsole(LogLevel.Information); } else if (testVerbose == "0") { _loggerFactory.AddConsole(LogLevel.Warning); } else { _loggerFactory.AddConsole(LogLevel.Error); } _testAssetsManager = new TestAssetsManager( Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "DthTestProjects", "src")); }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(LogLevel.Debug); app.UseStaticFiles(); 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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); 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) { 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); }
// Configure is called after ConfigureServices is called. public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, MyHealthDataInitializer dataInitializer) { loggerFactory.MinimumLevel = LogLevel.Information; loggerFactory.AddConsole(); loggerFactory.AddDebug(); // Configure the HTTP request pipeline. // Add the following to the request pipeline only in development environment. if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(options => options.EnableAll()); } 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 the platform handler to the request pipeline. app.UseIISPlatformHandler(); // Add static files to the request pipeline. app.UseStaticFiles(); // Add MVC to the request pipeline. app.ConfigureRoutes(); await dataInitializer.InitializeDatabaseAsync(app.ApplicationServices, Configuration); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.MinimumLevel = LogLevel.Debug; loggerFactory.AddConsole(); ConfigureApplication(app); }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); app.UseIISPlatformHandler(); app.Use((context, next) => { if (context.Request.Path.Equals("/Anonymous")) { return context.Response.WriteAsync("Anonymous?" + !context.User.Identity.IsAuthenticated); } if (context.Request.Path.Equals("/Restricted")) { if (context.User.Identity.IsAuthenticated) { return context.Response.WriteAsync(context.User.Identity.AuthenticationType); } else { return context.Authentication.ChallengeAsync(); } } if (context.Request.Path.Equals("/Forbidden")) { return context.Authentication.ForbidAsync(string.Empty); } if (context.Request.Path.Equals("/AutoForbid")) { return context.Authentication.ChallengeAsync(); } if (context.Request.Path.Equals("/RestrictedNegotiate")) { if (string.Equals("Negotiate", context.User.Identity.AuthenticationType, System.StringComparison.Ordinal)) { return context.Response.WriteAsync("Negotiate"); } else { return context.Authentication.ChallengeAsync("Negotiate"); } } if (context.Request.Path.Equals("/RestrictedNTLM")) { if (string.Equals("NTLM", context.User.Identity.AuthenticationType, System.StringComparison.Ordinal)) { return context.Response.WriteAsync("NTLM"); } else { return context.Authentication.ChallengeAsync("NTLM"); } } return context.Response.WriteAsync("Hello World"); }); }
// 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); }
// Configure is called after ConfigureServices is called. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { if(env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } loggerFactory .AddConsole(Configuration.GetSection("Logging")) .AddDebug(); // Use the Default files ['index.html', 'index.htm', 'default.html', 'default.htm'] app.UseDefaultFiles() .UseStaticFiles() .UseIISPlatformHandler() .UseMvc(); // Setup a generic Quotes API EndPoint app.Map("/api/quotes", (config) => { app.Run(async context => { var quotes = "{ \"quotes\":" + " [ { \"quote\": \"Duct tape is like the force. It has a light side, a dark side, and it holds the universe together.\", \"author\":\"Oprah Winfrey\"} ]" + "}"; context.Response.ContentLength = quotes.Length; context.Response.ContentType = "application/json"; await context.Response.WriteAsync(quotes); }); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); loggerFactory.AddDebug(); app.UseIISPlatformHandler(); app.UseCors(policy => { policy.WithOrigins( "http://localhost:28895", "http://localhost:7017"); policy.AllowAnyHeader(); policy.AllowAnyMethod(); }); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); app.UseIdentityServerAuthentication(options => { options.Authority = Clients.Constants.BaseAddress; options.ScopeName = "api1"; options.ScopeSecret = "secret"; options.AutomaticAuthenticate = true; options.AutomaticChallenge = true; }); app.UseMvc(); }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(LogLevel.Verbose); loggerFactory.AddDebug(LogLevel.Verbose); app.UseStaticFiles(); app.UseIdentityServer(); }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) { loggerfactory.AddConsole(LogLevel.Information); app.UseCookieAuthentication(options => { options.AutomaticAuthenticate = true; }); app.Run(async context => { if (!context.User.Identities.Any(identity => identity.IsAuthenticated)) { var user = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "bob") }, CookieAuthenticationDefaults.AuthenticationScheme)); await context.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, user); context.Response.ContentType = "text/plain"; await context.Response.WriteAsync("Hello First timer"); return; } context.Response.ContentType = "text/plain"; await context.Response.WriteAsync("Hello old timer"); }); }
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); }); }
// 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(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } var jwtBearerOptions = new JwtBearerOptions { AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme, AutomaticAuthenticate = true }; jwtBearerOptions.SecurityTokenValidators.Clear(); jwtBearerOptions.SecurityTokenValidators.Add(new TicketDataFormatTokenValidator()); app.UseJwtBearerAuthentication(jwtBearerOptions); app.UseMvc( routes => { routes.MapRoute( "WebApi", "api/{controller}/{action}/{id?}", new { action = "Get" } ); } ); }
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 void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.MinimumLevel = LogLevel.Information; loggerFactory.AddConsole(); loggerFactory.AddDebug(); // Configure the HTTP request pipeline. // Add the following to the request pipeline only in development environment. if (env.IsDevelopment()) { app.UseBrowserLink(); } // Add the platform handler to the request pipeline. app.UseIISPlatformHandler(); // 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?}"); }); }
// 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(LogLevel.Debug); app.Map( new PathString("/onboarding"), branch => branch.Run(async ctx => { await ctx.Response.WriteAsync("Onboarding"); }) ); app.UseMultitenancy<AppTenant>(); app.Use(async (ctx, next) => { if (ctx.GetTenant<AppTenant>().Name == "Default") { ctx.Response.Redirect("/onboarding"); } else { await next(); } }); app.UseMiddleware<LogTenantMiddleware>(); }
// Configure is called after ConfigureServices is called. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory, ApplicationDbContext context) { // Seeding data as EF7 doesn't support seeding data if (context.Courses.FirstOrDefault() == null) { context.Courses.Add(new Course { Title = "Basics of ASP.NET 5", Author = "Mahesh", Duration = 4 }); context.Courses.Add(new Course { Title = "Getting started with Grunt", Author = "Ravi", Duration = 3 }); context.Courses.Add(new Course { Title = "What's new in Angular 1.4", Author = "Ravi", Duration = 4 }); context.Courses.Add(new Course { Title = "Imagining JavaScript in ES6", Author = "Suprotim", Duration = 4 }); context.Courses.Add(new Course { Title = "C# Best Practices", Author = "Craig", Duration = 3 }); context.SaveChanges(); } // Configure the HTTP request pipeline. // Add the console logger. loggerfactory.AddConsole(minLevel: LogLevel.Warning); // Add the following to the request pipeline only in development environment. if (env.IsEnvironment("Development")) { app.UseBrowserLink(); app.UseErrorPage(ErrorPageOptions.ShowAll); app.UseDatabaseErrorPage(DatabaseErrorPageOptions.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"); } //app.UseDirectoryBrowser(); // Add static files to the request pipeline. app.UseStaticFiles(); // Add cookie-based authentication to the request pipeline. app.UseIdentity(); // Add authentication middleware to the request pipeline. You can configure options such as Id and Secret in the ConfigureServices method. // For more information see http://go.microsoft.com/fwlink/?LinkID=532715 // app.UseFacebookAuthentication(); // app.UseGoogleAuthentication(); // app.UseMicrosoftAccountAuthentication(); // app.UseTwitterAuthentication(); // Add MVC to the request pipeline. app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action}/{id?}", defaults: new { controller = "Home", action = "Index" }); // 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, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); app.UseIISPlatformHandler(); app.UseStaticFiles(); app.UseWelcomePage(); }
// 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, IHostingEnvironment env, ILoggerFactory loggerFactory) { JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); loggerFactory.AddConsole(); loggerFactory.AddDebug(); app.UseDeveloperExceptionPage(); app.UseStaticFiles(); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationScheme = "Cookies", AutomaticAuthenticate = true }); app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions { AuthenticationScheme = "oidc", SignInScheme = "Cookies", Authority = "https://demo.identityserver.io", PostLogoutRedirectUri = "http://localhost:3308/", ClientId = "hybrid", ClientSecret = "secret", ResponseType = "code id_token", GetClaimsFromUserInfoEndpoint = true, SaveTokens = true }); app.UseMvcWithDefaultRoute(); }
public RabbitMQPublisher(ILoggerFactory logger, RabbitMQConfiguration hostConfig) { _logger = logger? .AddConsole() .AddDebug() .CreateLogger <RabbitMQPublisher>() ?? throw new ArgumentNullException("Logger reference is required"); try { Validators.EnsureHostConfig(hostConfig); _hostConfig = hostConfig; exchange = _hostConfig.exchange; route = _hostConfig.routes.FirstOrDefault() ?? throw new ArgumentNullException("route queue is missing."); var host = Helper.ExtractHostStructure(_hostConfig.hostName); connectionFactory = new ConnectionFactory() { HostName = host.hostName, Port = host.port ?? defaultMiddlewarePort, UserName = _hostConfig.userName, Password = _hostConfig.password, ContinuationTimeout = TimeSpan.FromSeconds(DomainModels.System.Identifiers.TimeoutInSec) }; new Function(_logger, DomainModels.System.Identifiers.RetryCount).Decorate(() => { connection = connectionFactory.CreateConnection(); channel = connection.CreateModel(); return(true); }, (ex) => { switch (ex) { case BrokerUnreachableException brokerEx: return(true); case ConnectFailureException connEx: return(true); case SocketException socketEx: return(true); default: return(false); } }).Wait(); channel.ExchangeDeclare(exchange: exchange, type: ExchangeType.Topic, durable: true); props = channel.CreateBasicProperties(); props.Persistent = true; } catch (Exception ex) { _logger.LogError("Failed to initialize RabbitMQPublisher", ex); throw ex; } }
private RabbitMQPublisher(ILoggerFactory logger, RabbitMQConfiguration hostConfig) { this.logger = logger? .AddConsole() .AddDebug() .CreateLogger <RabbitMQPublisher>() ?? throw new ArgumentNullException("Logger reference is required"); Validators.EnsureHostConfig(hostConfig); this.hostConfig = hostConfig; this.connectionFactory = new ConnectionFactory() { HostName = hostConfig.hostName, UserName = hostConfig.userName, Password = hostConfig.password }; }
// 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"); }); }
// 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.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API v1"); }); var option = new RewriteOptions(); option.AddRedirect("^$", "swagger"); app.UseRewriter(option); app.UseMvc(routes => { routes.MapRoute( name: "DefaultApi", template: "{controller=Values}/{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(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseIdentity(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapRoute( name: "Landing", // Route name template: "{controller=Home}/{action=Landing}/{id?}"); }); // Enable middleware to serve generated Swagger as a JSON endpoint app.UseSwagger(); // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.) app.UseSwaggerUi(); }
// 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.AddDebug(); loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); using (var serviceScope = app.ApplicationServices.CreateScope()) { var ctx = serviceScope.ServiceProvider.GetService <IDatabaseInitializer>(); ctx.InitializeAsync(); } //app.ApplicationServices.GetService<IDatabaseInitializer>().InitializeAsync(); app.UseMvc(); }
public void Configure( IApplicationBuilder app, ILoggerFactory loggerFactory, IConfiguration configuration) { loggerFactory .AddConsole() .AddDebug(); var serveUnknown = configuration.GetValue <bool?>("serveUnknown") ?? false; if (serveUnknown) { app.UseStaticFiles(new StaticFileOptions { ServeUnknownFileTypes = true, DefaultContentType = "application/octet-stream" }); } else { app.UseFileServer(); } }
// 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, ILoggerFactory loggerFactory, IHttpContextAccessor accessor) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); app.UseMvc(); InMemoryBus.ContainerAccessor = () => accessor.HttpContext.RequestServices; }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseIdentity(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Account}/{action=Index}/{id?}"); }); 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, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); loggerFactory.AddDebug(LogLevel.Information); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseWebApiExceptionHandler(); } app.UseMvc(); app.UseSwagger(); app.UseSwaggerUI(config => { config.SwaggerEndpoint("/swagger/v1/swagger.json", "LogicXPro API"); }); //app.UseWelcomePage(); }
// 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.UseApplicationInsightsRequestTelemetry(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.UseSession(); app.UseIdentity(); // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715 app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); SeedData.EnsurePopulated(app); IdentitySeedData.EnsurePopulated(app); }
// 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, MarvinUserContext marvinUserContext, ConfigurationDbContext configurationDbContext) { loggerFactory.AddConsole(); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } configurationDbContext.Database.Migrate(); configurationDbContext.EnsureSeedDataForContext(); marvinUserContext.Database.Migrate(); marvinUserContext.EnsureSeedDataForContext(); app.UseIdentityServer(); // app.UseAuthentication(); //app.UseGoogleAuthentication(new GoogleOptions //{ // ClientId = "428263776906-migfnplkenutb2c9k79gi6kemcu2eqh3.apps.googleusercontent.com", // ClientSecret= "IVdCZw7YM_m0YzNnHlE0aX91", // SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme //}); app.UseStaticFiles(); app.UseMvcWithDefaultRoute(); //app.Run(async (context) => //{ // await context.Response.WriteAsync("Hello World!"); //}); }
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.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseStaticFiles(); //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.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, DoorKickerSeedData seeder) { loggerFactory.AddConsole(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseIdentity(); app.UseMvc(config => { config.MapRoute( name: "Default", template: "{controller}/{action}/{id?}", defaults: new { controller = "App", action = "Index" } ); }); seeder.EnsureSeedData().Wait(); }
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.UseCookieAuthentication(new CookieAuthenticationOptions() { AuthenticationScheme = "Cookies", LoginPath = new PathString("/Home/Login/"), AccessDeniedPath = new PathString("/Home/Forbidden/"), AutomaticAuthenticate = true, AutomaticChallenge = true }); 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(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseWebSockets(); app.Use(async (context, next) => { if (context.WebSockets.IsWebSocketRequest) { WebSocket webSocket = await context.WebSockets.AcceptWebSocketAsync(); await Echo(context, webSocket); } else { context.Response.StatusCode = 400; } }); }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(); // Simple error page without depending on Diagnostics. app.Use(async(context, next) => { try { await next(); } catch (Exception ex) { if (context.Response.HasStarted) { throw; } context.Response.Clear(); context.Response.StatusCode = 500; await context.Response.WriteAsync(ex.ToString()); } }); app.Use((context, next) => { if (context.Request.Path.Equals("/Anonymous")) { return(context.Response.WriteAsync("Anonymous?" + !context.User.Identity.IsAuthenticated)); } if (context.Request.Path.Equals("/Restricted")) { if (context.User.Identity.IsAuthenticated) { Assert.IsType <WindowsPrincipal>(context.User); return(context.Response.WriteAsync(context.User.Identity.AuthenticationType)); } else { return(context.Authentication.ChallengeAsync()); } } if (context.Request.Path.Equals("/Forbidden")) { return(context.Authentication.ForbidAsync(AuthenticationManager.AutomaticScheme)); } if (context.Request.Path.Equals("/AutoForbid")) { return(context.Authentication.ChallengeAsync()); } if (context.Request.Path.Equals("/RestrictedNegotiate")) { if (string.Equals("Negotiate", context.User.Identity.AuthenticationType, StringComparison.Ordinal)) { return(context.Response.WriteAsync("Negotiate")); } else { return(context.Authentication.ChallengeAsync("Negotiate")); } } if (context.Request.Path.Equals("/RestrictedNTLM")) { if (string.Equals("NTLM", context.User.Identity.AuthenticationType, StringComparison.Ordinal)) { return(context.Response.WriteAsync("NTLM")); } else { return(context.Authentication.ChallengeAsync("NTLM")); } } return(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, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); m_logger = loggerFactory.CreateLogger <Startup>(); DefaultFilesOptions options = new DefaultFilesOptions(); //options.DefaultFileNames.Clear(); options.DefaultFileNames.Add("index.html"); app.UseDefaultFiles(options); app.UseDefaultFiles(new DefaultFilesOptions() { FileProvider = new PhysicalFileProvider( BlogLocationUtil.GetBlogFilesLocation(env)), RequestPath = new PathString("/blog") }); app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider( BlogLocationUtil.GetBlogFilesLocation(env)), RequestPath = "/blog", OnPrepareResponse = ctx => { // Requires the following import: // using Microsoft.AspNetCore.Http; ctx.Context.Response.Headers.Append("Cache-Control", "public,max-age=600"); }, } ); //app.UseApplicationInsightsRequestTelemetry(); if (env.IsDevelopment()) { m_logger.LogInformation("Running in development mode"); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); app.UseBrowserLink(); } else { m_logger.LogInformation("Running in production mode"); app.UseExceptionHandler("/Home/Error"); } //app.UseStatusCodePagesWithRedirects("~/errors/code/{0}"); app.UseSecurityHeadersMiddleware(new SecurityHeadersBuilder() .AddDefaultSecurePolicy() ); //app.UseApplicationInsightsExceptionTelemetry(); app.UseAuthentication(); //AddExternalAuthentication(app); app.UseMvc(routes => { routes.MapRoute( name: "showTest", template: "{controller=Benchmarks}/{action=Show}/{id}/{version}/{name?}"); 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, IOptions <AegisOptions> aegisOptions, IOptions <ServerOptions> serverOptions, IOptions <RequestLocalizationOptions> l10nOptions, DbLoggerProvider dbLogProvider) { if (_environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/sys/error"); } // Https Rewriter if (serverOptions.Value.UseHttpsRewriter) { var rewriteOptions = new RewriteOptions().AddRedirectToHttps(); app.UseRewriter(rewriteOptions); } // logging //_loggerFactory.AddProvider(dbLogProvider); _loggerFactory.AddConsole(_configuration.GetSection("Logging")); _loggerFactory.AddDebug(LogLevel.Debug); // app components app.UseSession(); app.UseMultitenancy <SiteContext>(); app.UseRequestLocalization(l10nOptions.Value); app.UseStaticFiles(); app.UseKendo(_environment); // cookie policy app.UseCookiePolicy(new CookiePolicyOptions { HttpOnly = HttpOnlyPolicy.None, Secure = CookieSecurePolicy.SameAsRequest }); // openid security app.UsePerTenant <SiteContext>((ctx, builder) => { builder.UseAegisOidc(aegisOptions, ctx.Tenant); }); // Application migrations app.RunAppMigrations(); //validate Client Active Status //app.RunActiveClientValidation(); // configure plugins _plugins.Configure(app); // configure MVC convention based routes app.UseMvc(routes => { #region Ajax / Api Services //TODO: Cleanup Widget routes. Move behind sys/ routes.MapRoute( name: "admin", template: "admin/{controller=Dashboard}/{action=Index}/{id?}", defaults: new { area = "Admin" } ); //TODO: route behind "sys/" routes.MapRoute( name: "Ajax Components", template: "components/{type}/{cid?}", defaults: new { controller = "Components", action = "Render" } ); routes.MapRoute( name: "content", template: "sys/content/{action}", defaults: new { controller = "Content" } ); #endregion #region Back Office Routes //TODO: use "sys/account" instead routes.MapRoute( name: "User Account", template: "sys/account/{action=profile}", defaults: new { area = "Admin", controller = "Account" } ); routes.MapRoute( name: "Corp Admin", template: "sys/corp/admin/{action=dashboard}", defaults: new { area = "Admin", controller = "CorpAdmin" } ); routes.MapRoute( name: "Client Admin", template: "sys/clients/{tenant}/admin/{action=dashboard}", defaults: new { area = "Admin", controller = "ClientAdmin" } ); routes.MapRoute( name: "Site Admin", template: "sys/sites/{tenant}/admin/{action=dashboard}", defaults: new { area = "Admin", controller = "SiteAdmin" } ); #endregion #region CMS Front End Routes routes.MapRoute( name: "Notify Me", template: "sys/notifyme/{action}", defaults: new { area = "Public", controller = "NotifyMeSignUp" } ); //routes.MapRoute( // name: "Site Alerts", // template: "sys/sitealerts/{action}", // defaults: new { area = "Public", controller = "SiteAlerts" } //); routes.MapRoute( name: "Search", template: "sys/search/{action}", defaults: new { area = "Public", controller = "Search" } ); routes.MapRoute( name: "Page Provider by Route", template: "{*route}", defaults: new { area = "Public", controller = "SitePage", action = "RenderRoute", route = "/" } ); #endregion }); // enable jobs app.UseJobs(); //----------------------------------------------------------- // TODO: These need to go away - Convert to IAppMigrations // ----------------------------------------------------------- app.RunStartupActions(); _plugins.RunStartupActions(app); }
// 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) { app.UseCors(builder => { builder.WithOrigins("http://*****:*****@word12345678901234567890"; var bytes = Encoding.ASCII.GetBytes(secret); var signing = new SymmetricSecurityKey(bytes); var token = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = signing, ValidateIssuer = true, ValidIssuer = "Issuer", ValidateAudience = true, ValidAudience = "Audience", RequireExpirationTime = true, ValidateLifetime = true, ClockSkew = TimeSpan.Zero }; var options = new TokenProviderOptions { Audience = "Audience", Issuer = "Issuer", SigningCredentials = new SigningCredentials(signing, SecurityAlgorithms.HmacSha256) }; app.UseMiddleware <TokenProviderMiddleware>(Options.Create(options)); app.UseJwtBearerAuthentication(new JwtBearerOptions() { AutomaticAuthenticate = true, AutomaticChallenge = true, TokenValidationParameters = token }); app.UseCookieAuthentication(new CookieAuthenticationOptions() { CookieHttpOnly = true, AutomaticAuthenticate = true, AutomaticChallenge = true, AuthenticationScheme = "Cookie", CookieName = "access_token", TicketDataFormat = new CustomJwt( SecurityAlgorithms.HmacSha256, token) }); 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) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(LogLevel.Warning); loggerFactory.AddFile(Configuration.GetSection("Logging")); Utilities.ConfigureLogger(loggerFactory); EmailTemplates.Initialize(env); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // Enforce https during production //var rewriteOptions = new RewriteOptions() // .AddRedirectToHttps(); //app.UseRewriter(rewriteOptions); app.UseExceptionHandler("/Home/Error"); } //Configure Cors app.UseCors(builder => builder .AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod()); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseAuthentication(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "AAS.LiveApp.WebClient API V1"); }); 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, IHostingEnvironment env, IConfiguration configuration, ILogger <Startup> logger, ClaimContext claimcontext, IGST gST, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(configuration.GetSection("Logging")); loggerFactory.AddDebug(); loggerFactory.AddSerilog(); Log.Logger = new LoggerConfiguration() .MinimumLevel .Information() .WriteTo.RollingFile("Log - {Date}.txt", LogEventLevel.Information) .CreateLogger(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { //Global error handling for Exception app.UseExceptionHandler(appBuilder => { appBuilder.Run(async context => { context.Response.StatusCode = 500; await context.Response.WriteAsync("An Unexpected fault happened. Try again later." + "If issue persists, contac Administrator"); }); }); } //Set appbuilder to serve request incase for static file app.UseFileServer(); //AutoMapper AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <Expenses, ClaimsDto>() .ForMember(dest => dest.costCenter, opt => opt.MapFrom(src => src.CostCenterId)) .ForMember(dest => dest.date, opt => opt.MapFrom(src => src.TransactionDate)) .ForMember(dest => dest.total, opt => opt.MapFrom(src => src.TotalAmount)) .ForMember(dest => dest.gstCalculated, opt => opt.MapFrom(src => gST.CalculateGST(src.TotalAmount))); cfg.CreateMap <ClaimsDto, Expenses>() .ForMember(dest => dest.CostCenterId, opt => opt.MapFrom(src => src.costCenter)) .ForMember(dest => dest.TransactionDate, opt => opt.MapFrom(src => src.date)) .ForMember(dest => dest.CreatedAt, opt => opt.MapFrom(src => DateTime.Now)) .ForMember(dest => dest.TotalAmount, opt => opt.MapFrom(src => src.total)) .ForMember(dest => dest.CostCenter, opt => opt.Ignore()); }); //Set middleware of MVC //app.UseMvcWithDefaultRoute(); if (!claimcontext.Expenses.Any()) { claimcontext.EnsureSeedDataForClaim(); } //Convention Base Route app.UseMvc(); app.Run(async(context) => { var greeting = configuration["Greeting"]; await context.Response.WriteAsync(greeting); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // you can add things to this method signature and they will be injected as long as they were registered during // ConfigureServices public void Configure( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IOptions <cloudscribe.Core.Models.MultiTenantOptions> multiTenantOptionsAccessor, IServiceProvider serviceProvider, IOptions <RequestLocalizationOptions> localizationOptionsAccessor, cloudscribe.Logging.Web.ILogRepository logRepo ) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); ConfigureLogging(loggerFactory, serviceProvider, logRepo); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseForwardedHeaders(); app.UseStaticFiles(); app.UseSession(); app.UseRequestLocalization(localizationOptionsAccessor.Value); app.UseMultitenancy <cloudscribe.Core.Models.SiteContext>(); var multiTenantOptions = multiTenantOptionsAccessor.Value; app.UsePerTenant <cloudscribe.Core.Models.SiteContext>((ctx, builder) => { // custom 404 and error page - this preserves the status code (ie 404) if (string.IsNullOrEmpty(ctx.Tenant.SiteFolderName)) { builder.UseStatusCodePagesWithReExecute("/Home/Error/{0}"); } else { builder.UseStatusCodePagesWithReExecute("/" + ctx.Tenant.SiteFolderName + "/Home/Error/{0}"); } builder.UseCloudscribeCoreDefaultAuthentication( loggerFactory, multiTenantOptions, ctx.Tenant); // to make this multi tenant for folders // using a fork of IdentityServer4 and hoping to get changes so we don't need a fork // https://github.com/IdentityServer/IdentityServer4/issues/19 builder.UseIdentityServer(); // this sets up the authentication for apis within this application endpoint // ie apis that are hosted in the same web app endpoint with the authority server // this is not needed here if you are only using separate api endpoints // it is needed in the startup of those separate endpoints //builder.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions //{ // Authority = "https://localhost:5000", // // using the site aliasid as the scope so each tenant has a different scope // // you can view the aliasid from site settings // // clients must be configured with the scope to have access to the apis for the tenant // ApiName = ctx.Tenant.AliasId, // RequireHttpsMetadata = false //}); }); UseMvc(app, multiTenantOptions.Mode == cloudscribe.Core.Models.MultiTenantMode.FolderName); CoreNoDbStartup.InitializeDataAsync(app.ApplicationServices).Wait(); CloudscribeIdentityServerIntegrationNoDbStorage.InitializeDatabaseAsync(app.ApplicationServices).Wait(); }
// 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, IHttpContextAccessor httpContextAccessor) { //Security headers app.UseHsts(options => options.MaxAge(days: 365)); //TODO: AJS FIX UNSAFEEVAL AFTER INCLUDING ANGULAR JS app.UseCsp(options => options.DefaultSources(s => s.Self()) .ScriptSources(s => s.Self().CustomSources("ajax.aspnetcdn.com", "code.jquery.com").UnsafeEval()) .StyleSources(s => s.Self().UnsafeInline()) .ImageSources(s => s.Self().CustomSources("secure.gravatar.com"))); app.UseXXssProtection(option => option.EnabledWithBlockMode()); app.UseXfo(options => options.Deny()); app.UseXContentTypeOptions(); loggerFactory.AddProvider(new FileLoggerProvider()); //////////////////////////////////////////////////////////////// // TODO: Authorize Attribute Re-routing to '~/Account/Login' //app.UseCookieAuthentication(new CookieAuthenticationOptions //{ // AuthenticationScheme = Constants.JabbRAuthType, // LoginPath = new PathString("/Account/Login/"), // AccessDeniedPath = new PathString("/Account/Forbidden/"), // AutomaticAuthenticate = true, // run with every request and look for cookie if available // AutomaticChallenge = true, // take raw 401 and 403 and use redirect paths as defined // CookieName = "jabbr.id" //}); //////////////////////////////////////////////////////////////// if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } loggerFactory.AddConsole(); app.UseStaticFiles(); app.UseIdentity(); app.UseFacebookAuthentication(new FacebookOptions() { AppId = _configuration["Authentication:Facebook:AppId"], AppSecret = _configuration["Authentication:Facebook:AppSecret"] }); //app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions() //{ // ClientId = _configuration["Authentication:Microsoft:AppId"], // ClientSecret = _configuration["Authentication:Microsoft:AppSecret"] //}); app.UseGoogleAuthentication(new GoogleOptions() { ClientId = _configuration["Authentication:Google:AppId"], ClientSecret = _configuration["Authentication:Google:AppSecret"] }); //app.UseTwitterAuthentication(new TwitterOptions() //{ // ConsumerKey = _configuration["Authentication:Twitter:AppId"], // ConsumerSecret = _configuration["Authentication:Twitter:AppSecret"], //}); app.UseMvcWithDefaultRoute(); app.UseSignalR(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger) { logger.AddConsole((str, level) => !str.Contains("Microsoft.AspNetCore") && level >= LogLevel.Trace); var log = logger.CreateLogger(""); app.UseWebSockets(); var cm = new ConnectionManager(); int count = 0; app.Use(async(context, next) => { if (!context.WebSockets.IsWebSocketRequest) { await next(); return; } var socket = await context.WebSockets.AcceptWebSocketAsync(); var socketId = cm.AddSocket(socket); await ReceiveAsync(log, socket, socketId, async(clientRequest) => { var serverReply = Encoding.UTF8.GetBytes($"Echo {++count} {clientRequest}"); var replyBuffer = new ArraySegment <byte>(serverReply); await socket.SendAsync(replyBuffer, WebSocketMessageType.Text, true, CancellationToken.None); var broadcastReply = Encoding.UTF8.GetBytes($"Broadcast {count} {clientRequest}"); var broadcastBuffer = new ArraySegment <byte>(broadcastReply); var socketTasks = new List <Task>(); foreach (var(s, sid) in cm.Other(socketId)) { socketTasks.Add(s.SendAsync(broadcastBuffer, WebSocketMessageType.Text, true, CancellationToken.None)); log.LogDebug($"Broadcasting to : {sid}"); } await Task.WhenAll(socketTasks); }); }); app.Run(async context => { context.Response.Headers.Add("content-type", "text/html"); await context.Response.WriteAsync(@" <html> <head> <script src=""https://code.jquery.com/jquery-3.2.1.min.js"" integrity=""sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="" crossorigin=""anonymous""></script> </head> <body> <h1>Web Socket (please open this page at 2 tabs at least)</h1> <input type=""text"" length=""50"" id=""msg"" value=""hello world""/> <button type=""button"" id=""send"">Send</button> <br/> <ul id=""responses""></ul> <script> $(function(){ var url = ""ws://localhost:5000""; var socket = new WebSocket(url); var send = $(""#send""); var msg = $(""#msg""); var responses = $(""#responses""); socket.onopen = function(e){ send.click(function(){ socket.send(msg.val()); }); }; socket.onmessage = function(e){ var response = e.data; responses.append(`<li>${e.data.trim()}</li>`); }; }); </script> </body> </html>"); }); }
// 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.UseDatabaseErrorPage(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // 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()) { serviceScope.ServiceProvider.GetService <ApplicationDbContext>() .Database.Migrate(); } } catch (Exception) { } } app.UseRequestLocalization(new RequestLocalizationOptions() { SupportedCultures = new List <CultureInfo> { new CultureInfo("en-US"), new CultureInfo("nl-NL") }, SupportedUICultures = new List <CultureInfo> { new CultureInfo("en-US"), new CultureInfo("nl-NL") }, }, new RequestCulture(new CultureInfo("nl-NL"))); app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear()); app.UseStaticFiles(); app.UseIdentity(); var onRemoteError = new OAuthEvents() { OnRemoteError = ctx => { ctx.Response.Redirect("/Account/ExternalLoginCallback?RemoteError=" + UrlEncoder.Default.UrlEncode(ctx.Error.Message)); ctx.HandleResponse(); return(Task.FromResult(0)); } }; // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715 if (Configuration["Authentication:Google:ClientId"] != null) { app.UseFacebookAuthentication(options => { options.AppId = Configuration["Authentication:Facebook:AppId"]; options.AppSecret = Configuration["Authentication:Facebook:AppSecret"]; options.DisplayName = "facebook"; options.Events = onRemoteError; }); app.UseGoogleAuthentication(options => { options.ClientId = Configuration["Authentication:Google:ClientId"]; options.ClientSecret = Configuration["Authentication:Google:ClientSecret"]; options.DisplayName = "google plus"; options.Events = onRemoteError; }); } app.UseCacheWrite(); 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, EntidadesContexto contexto) { 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?}"); }); /* * GLPKInput teste = new GLPKInput( ); * * teste.Variables.Add( "x" ); * teste.Variables.Add( "y" ); * * GLPKRestriction r1 = new GLPKRestriction( ); * r1.Values.Add( 10 ); * r1.Values.Add( 20 ); * r1.Operation = GLPKRestriction.Operator.GreaterOrEqual; * r1.Disponibility = 2; * * GLPKRestriction r2 = new GLPKRestriction( ); * r2.Values.Add( 40 ); * r2.Values.Add( 60 ); * r2.Operation = GLPKRestriction.Operator.GreaterOrEqual; * r2.Disponibility = 64; * * GLPKRestriction r3 = new GLPKRestriction( ); * r3.Values.Add( 50 ); * r3.Values.Add( 20 ); * r3.Operation = GLPKRestriction.Operator.GreaterOrEqual; * r3.Disponibility = 34; * * teste.Restrictions.Add( r1 ); * teste.Restrictions.Add( r2 ); * teste.Restrictions.Add( r3 ); * * teste.Objective.Values.Add( 0.6 ); * teste.Objective.Values.Add( 0.8 ); * * var hy = JsonConvert.SerializeObject( teste ); * Console.Write( hy );*/ //string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User) + ";" + Directory.GetCurrentDirectory(); //Environment.SetEnvironmentVariable("Path", path, EnvironmentVariableTarget.User); //var model = new Model(); //var x = new Variable("x"); //var y = new Variable("y"); //model.AddConstraint(10 * x + 20 * y >= 2); //model.AddConstraint(40 * x + 60 * y >= 64); //model.AddConstraint(50 * x + 20 * y >= 34); //model.AddObjective(new Objective(0.6 * x + 0.8 * y)); //var solver = new GLPKSolver(); //solver.Solve(model); //var solution = solver.Solve(model); InicializaBD.Initialize(contexto); }
/// <summary> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app"></param> /// <param name="env"></param> /// <param name="loggerFactory"></param> public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory // ,IOptionsMonitor<GeneralSettings> generalSettings, // IOptionsMonitor<TaxonomySettings> taxonomySettings, // IOptionsMonitor<MatterSettings> matterSettings, // IOptionsMonitor<DocumentSettings> documentSettings, // IOptionsMonitor<SharedSettings> sharedSettings, // IOptionsMonitor<MailSettings> mailSettings, // IOptionsMonitor<ListNames> listNames, // IOptionsMonitor<LogTables> logTables, // IOptionsMonitor<SearchSettings> searchSettings, // IOptionsMonitor<CamlQueries> camlQueries, // IOptionsMonitor<ContentTypesConfig> contentTypesConfig, // IOptionsMonitor<MatterCenterApplicationInsights> matterCenterApplicationInsights ) { CreateConfig(env); var log = loggerFactory.CreateLogger <Startup>(); try { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); //generalSettings.OnChange(genSettings => { // loggerFactory // .CreateLogger<IOptions<GeneralSettings>>() // .LogDebug($"Config changed: {string.Join(", ", genSettings)}"); //}); //taxonomySettings.OnChange(taxSettings => { // loggerFactory // .CreateLogger<IOptions<TaxonomySettings>>() // .LogDebug($"Config changed: {string.Join(", ", taxSettings)}"); //}); //matterSettings.OnChange(matSettings => { // loggerFactory // .CreateLogger<IOptions<MatterSettings>>() // .LogDebug($"Config changed: {string.Join(", ", matSettings)}"); //}); //documentSettings.OnChange(docSettings => { // loggerFactory // .CreateLogger<IOptions<DocumentSettings>>() // .LogDebug($"Config changed: {string.Join(", ", docSettings)}"); //}); //sharedSettings.OnChange(shrdSettings => { // loggerFactory // .CreateLogger<IOptions<SharedSettings>>() // .LogDebug($"Config changed: {string.Join(", ", shrdSettings)}"); //}); //mailSettings.OnChange(mlSettings => { // loggerFactory // .CreateLogger<IOptions<MailSettings>>() // .LogDebug($"Config changed: {string.Join(", ", mlSettings)}"); //}); //listNames.OnChange(lstNames => { // loggerFactory // .CreateLogger<IOptions<ListNames>>() // .LogDebug($"Config changed: {string.Join(", ", lstNames)}"); //}); //logTables.OnChange(logSettings => { // loggerFactory // .CreateLogger<IOptions<LogTables>>() // .LogDebug($"Config changed: {string.Join(", ", logSettings)}"); //}); //searchSettings.OnChange(srchSettings => { // loggerFactory // .CreateLogger<IOptions<SearchSettings>>() // .LogDebug($"Config changed: {string.Join(", ", srchSettings)}"); //}); //camlQueries.OnChange(camlSettings => { // loggerFactory // .CreateLogger<IOptions<CamlQueries>>() // .LogDebug($"Config changed: {string.Join(", ", camlSettings)}"); //}); //contentTypesConfig.OnChange(ctpSettings => { // loggerFactory // .CreateLogger<IOptions<ContentTypesConfig>>() // .LogDebug($"Config changed: {string.Join(", ", ctpSettings)}"); //}); //matterCenterApplicationInsights.OnChange(appInsightSettings => { // loggerFactory // .CreateLogger<IOptions<MatterCenterApplicationInsights>>() // .LogDebug($"Config changed: {string.Join(", ", appInsightSettings)}"); //}); app.UseApplicationInsightsRequestTelemetry(); if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseApplicationInsightsExceptionTelemetry(); app.UseDefaultFiles(); app.UseStaticFiles(); CheckAuthorization(app); app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()); app.UseMvc(); app.UseSwagger(); app.UseSwaggerUi(); } catch (Exception ex) { app.Run( async context => { log.LogError($"{ex.Message}"); context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; context.Response.ContentType = "text/plain"; await context.Response.WriteAsync(ex.Message).ConfigureAwait(false); await context.Response.WriteAsync(ex.StackTrace).ConfigureAwait(false); }); } }
// 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.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseWebMarkupMin(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.MinimumLevel = LogLevel.Information; loggerFactory.AddConsole(); if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase)) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseIISPlatformHandler(); app.UseStaticFiles(); app.UseCookieAuthentication(options => { options.AuthenticationScheme = Constants.MiddlewareScheme; options.LoginPath = new PathString("/Account/Login/"); options.AccessDeniedPath = new PathString("/Account/Forbidden/"); options.AutomaticAuthenticate = true; options.AutomaticChallenge = true; }); 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(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(), @"Pictures")), RequestPath = new PathString("/Pictures") }); app.UseMiddleware<CatifyMiddleware>(); 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(); app.UseApplicationInsightsRequestTelemetry(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseApplicationInsightsExceptionTelemetry(); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute("areaRoute", "{area:exists}/{controller=RequireJs}/{action=Index}/{id?}"); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// Configure is called after ConfigureServices is called. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); // Add the following to the request pipeline only in development environment. if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // Add Error handling middleware which catches all application specific errors and // send the request to the following path or controller action. app.UseExceptionHandler("/Home/Error"); } // Add the platform handler to the request pipeline. app.UseIISPlatformHandler(); // 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?}"); routes.MapRoute("DefaultApi", "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(); _logger = loggerFactory.CreateLogger("Test"); _logger.LogInformation("Starting Jacks logging"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseIISPlatformHandler(); app.UseStaticFiles(); app.UseSignalR2(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); _dm = new DownloadManager(_logger, GlobalHost.ConnectionManager.GetHubContext<Scraper.Hubs.ChatHub>()); Console.CancelKeyPress += (s,e) => { _logger.LogInformation("CTRL+C detected - shutting down"); _dm.Stop(); }; }