Ejemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env,
                              ILoggerFactory loggerFactory, Microsoft.AspNetCore.Hosting.IApplicationLifetime appLifetime)
        {
            // loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            // loggerFactory.AddDebug();
            loggerFactory.AddNLog();
            app.AddNLogWeb();
            env.ConfigureNLog("nlog.config");

            var jwtSettings = app.ApplicationServices.GetService <IOptions <JwtSettings> >();

            app.UseJwtBearerAuthentication(new JwtBearerOptions
            {
                AutomaticAuthenticate     = true,
                TokenValidationParameters = new TokenValidationParameters
                {
                    ValidIssuer      = jwtSettings.Value.Issuer,
                    ValidateAudience = false,
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings.Value.Key))
                }
            });
            SeedData(app);
            app.UseErrorHandler();
            app.UseMvc();
            appLifetime.ApplicationStopped.Register(() => Container.Dispose());
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              Microsoft.AspNetCore.Hosting.IHostingEnvironment env,
                              ILoggerFactory loggerFactory)
        {
            //Nlog
            env.ConfigureNLog("NLog.config");
            //add NLog to ASP.NET Core
            loggerFactory.AddNLog();
            //Webserver stuff
            app.UseAuthentication();
            app.UseExceptionHandler("/Home/Error");
            app.UseStatusCodePages();
            app.UseResponseCompression();
            // app.UseDeveloperExceptionPage();
            app.UseStaticFiles();
            //Fall back for SPA
            app.MapWhen(context => context.Request.Path.Value.StartsWith("/App"), builder =>
            {
                builder.UseMvc(routes =>
                {
                    routes.MapSpaFallbackRoute("spa-fallback", new { controller = "Home", action = "Index" });
                });
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}");
                routes.MapRoute(
                    name: "api",
                    template: "API/{controller}/{action}");
                // This causes wrong URL to fallback to app which feels weird
                // routes.MapSpaFallbackRoute(
                //     name: "spa-fallback",
                //     defaults: new { controller = "Home", action = "Index" });
            });
        }
Ejemplo n.º 3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Swagger- autodocument
            app.UseStaticFiles();
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Signature Service");
            });

            // JWT/OAuth pipeline
            app.UseMiddleware <AuthenticationMiddleware>(new JsonConfiguration());


            app.UseCors("CorsPolicy");

            app.UseMvc();


            // Nlog database log file

            var defaultConnection = Configuration.GetConnectionString("NLogDb");

            NLog.GlobalDiagnosticsContext.Set("defaultConnection", defaultConnection);

            env.ConfigureNLog("nlog.config");
            loggerFactory.AddNLog();

            var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();

            logger.Info("Signature service started.");
        }
Ejemplo n.º 4
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app,
                       Microsoft.AspNetCore.Hosting.IHostingEnvironment env,
                       ILoggerFactory loggerFactory)
 {
     #if DEBUG
     env.EnvironmentName = "Development";
     #else
     env.EnvironmentName = "Production";
     #endif
     //Nlog
     env.ConfigureNLog("NLog.config");
     //add NLog to ASP.NET Core
     loggerFactory.AddNLog();
     app.UseAuthentication();
     app.UseResponseCompression();
     app.UseDeveloperExceptionPage();
     app.UseStaticFiles();
     app.UseSignalR(routes =>
     {
         routes.MapHub <FixturesFeed>("/Livefeed");
     });
     app.UseMvc(routes =>
     {
         routes.MapRoute(
             name: "default",
             template: "{controller=Home}/{action=Index}");
         routes.MapRoute(
             name: "api",
             template: "API/{controller}/{action}");
         //Use this to fallback route in case of using vue router heavily
         //Install - Package Microsoft.AspNetCore.SpaServices
         routes.MapSpaFallbackRoute(
             name: "spa-fallback",
             defaults: new { controller = "Home", action = "Index" });
     });
 }