Beispiel #1
0
        // 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, WorldContextSeedData seeder)
        {
            Mapper.Initialize(config => {
                config.CreateMap <TripViewModel, Trip>()
                .ForMember(trip => trip.DateCreated, tripViewModel => tripViewModel.MapFrom(model => model.Created))
                .ReverseMap();

                config.CreateMap <StopViewModel, Stop>()
                .ReverseMap();
            });

            //loggerFactory.AddConsole();

            //if (env.IsDevelopment())
            //{
            //    app.UseDeveloperExceptionPage();
            //}

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("<html><body><h3>Hello World!</h3></body></html>");
            //});

            //app.UseDefaultFiles(); Para usar index.html como página de inicio. En su lugar se usará la vista index.cshtml
            if (env.IsEnvironment("Development"))
            {
                app.UseDeveloperExceptionPage(); //Para evitar la pantalla en blanco y que muestre el error
                loggerFactory.CreateLogger("The world logger");
                //Ejemplo de uso: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging
                //Inyectar en la clase a usar, p.e: en tripsController como ILogger<TripsController> logger
            }

            loggerFactory.CreateLogger("The world logger");

            app.UseStaticFiles();

            app.UseIdentity();

            //Para que haga uso de MVC y así valla a index.cshtml

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" } //Página de inicio por defecto
                    );
            });

            seeder.SeedData().Wait();
        }
Beispiel #2
0
        // 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,
                              WorldContextSeedData seeder, ILoggerFactory loggingFactory)
        {
            Mapper.Initialize(config =>
            {
                config.CreateMap <TripViewModel, Trip>().ReverseMap();
                config.CreateMap <StopViewModel, Stop>().ReverseMap();
            });

            loggerFactory.AddConsole();

            if (!env.IsEnvironment("Production"))
            {
                app.UseDeveloperExceptionPage();
                loggingFactory.AddDebug(LogLevel.Information);
            }
            else
            {
                loggingFactory.AddDebug(LogLevel.Error);
            }
            app.UseStaticFiles();
            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index", id = "" }
                    );
            });

            seeder.SeedData().Wait();
            //app.UseStaticFiles();

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("Hello World!");
            //});
        }