Ejemplo n.º 1
0
        //This method is invoked when ASPNET_ENV is 'Development' or is not defined
        //The allowed values are Development,Staging and Production
        //public void ConfigureDevelopment(IApplicationBuilder app, ILoggerFactory loggerFactory)
        //{
        //    loggerFactory.AddConsole(minLevel: LogLevel.Warning);

        //Helps with auto page reloading and intergration with VS
        //app.UseBrowserLink();
        //        //Get useful information for exceptions
        //        app.UseDeveloperExceptionPage();
        //        //Displays database related error details
        //        app.UseDatabaseErrorPage();
        //        // Add the runtime information page that can be used by developers
        //        // to see what packages are used by the application
        //        // default path is: /runtimeinfo
        //        app.UseRuntimeInfoPage();

        //    Configure(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)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug(LogLevel.Information);
            app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
            //app.UseMiddleware<FeelTheForceMiddleware>();
            app.UseFeelTheForce();
            if (env.IsDevelopment())
            {
                //Helps with auto page reloading and intergration with VS
                app.UseBrowserLink();
                //Get useful information for exceptions
                app.UseDeveloperExceptionPage();
                //Displays database related error details
                app.UseDatabaseErrorPage();
                // Add the runtime information page that can be used by developers
                // to see what packages are used by the application
                // default path is: /runtimeinfo
                app.UseRuntimeInfoPage();
            }
            else
            {
                //Where to go when we get an Exception
                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 { }
            }


            var useGlimpse = Configuration.Get<bool>("Glimpse:Enabled");
            if (useGlimpse)
            {
                app.UseGlimpse();
            }

            //Alllow hosting static files
            app.UseStaticFiles();

            //Enabled Asp.Net Identity
            app.UseIdentity();

            //// To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715
            //app.UseCors(a => a.AllowAnyOrigin());
            //Setup routing
            app.UseMvc(routes =>
            {

                routes.UseTypedRouting();
                routes.MapRoute(
      name: "default",
      template: "{controller=Home}/{action=About}/{id?}");
            });
        }