Exemple #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)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }


            // Enable static files as css and js
            app.UseStaticFiles();

            // Allows the session system to auto associate requests with sessions when arriving from the client
            app.UseSession();

            app.UseAuthentication(); // app.UseIdentity() will be removed

            app.UseMvc(routes =>
            {
                //Improve routing for pagination
                //routes.MapRoute(
                //    name: null,
                //    template: "{category}/Page{productPage:int}",
                //    defaults: new { Controller = "Product", action = "List" });

                //routes.MapRoute(
                //    name: null,
                //    template: "Page{productPage:int}",
                //    defaults: new { Controller = "Product", action = "List", productPage = 1 });

                //routes.MapRoute(
                //    name: null,
                //    template: "{category}",
                //    defaults: new { Controller = "Product", action = "List", productPage = 1 });

                //routes.MapRoute(
                //    name: null,
                //    template: "",
                //    defaults: new { Controller = "Product", action = "List", productPage = 1 });

                //routes.MapRoute(
                //    name: null,
                //    template: "{controller}/{action}/{id?}");

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



            // Populate with product/ingredient
            SeedData.EnsurePopulated(app);

            new UserRoleSeed(app.ApplicationServices.GetService <RoleManager <IdentityRole> >()).Seed();

            // Ensure admin user
            IdentitySeed.EnsurePopulated(app);
        }