Esempio n. 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, TheWorldContextSeedData seeder, ILoggerFactory loggerFactory,
                              IHostingEnvironment env)
        {
            loggerFactory.AddDebug(LogLevel.Warning);

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

            app.UseStaticFiles();

            app.UseIdentity();

            Mapper.Initialize(config =>
            {
                config.CreateMap <Trip, TripViewModel>().ReverseMap();
                config.CreateMap <Stop, StopViewModel>().ReverseMap();
            });

            app.UseMvc(config =>
            {
                config.MapRoute(
                    name: "Default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "App", action = "Index" }
                    );
            });

            seeder.EnsureSeedData();
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public async void Configure(IApplicationBuilder app,
                                    TheWorldContextSeedData seeder,
                                    ILoggerFactory loggerFactory,
                                    IHostingEnvironment env)
        {
            try
            {
                if (env.IsDevelopment())
                {
                    // change logging level, exception handling, etc..
                }
                else
                {
                }

                app.UseRuntimeInfoPage();  // go to /runtimeinfo page

                // logger has debug/console out of the box.  use AddProvider() to hook up your own
                loggerFactory.AddConsole(LogLevel.Debug);

                //app.UseDefaultFiles(); //mvc will handle this..dont'want to serve index.html
                app.UseStaticFiles();

                app.UseIdentity();

                // Mappings
                Mapper.Initialize(config =>
                {
                    config.CreateMap <Trip, TripViewModel>().ReverseMap();
                    config.CreateMap <Stop, StopViewModel>().ReverseMap();
                }
                                  );

                // Routes
                app.UseMvc(config =>
                {
                    config.MapRoute(
                        name: "Default",
                        template: "{controller}/{action}/{id?}",
                        defaults: new { controller = "App", action = "Index" }
                        );
                }
                           );


                //  Data seed/prep (only a 1-time thing...or use it to update schema?)
                await seeder.EnsureSeedDataAsync();

                //app.UseIISPlatformHandler();

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


                //app.Run(async (context) =>
                //{
                //    if (context.Request.Query.ContainsKey("throw"))
                //    {

                //        throw new Exception("Exception triggered!");
                //    }
                //    await context.Response.WriteAsync("EXCEPTION in Configure: " + e.ToString());
                //});
            }
            catch (Exception e)
            {
                app.Run(async(context) =>
                {
                    await context.Response.WriteAsync("EXCEPTION in Configure: " + e.ToString());
                });
            }
        }