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, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseStaticFiles();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}"
                    );
            });
            using (var scope = app.ApplicationServices.CreateScope())
            {
                AppDbContext context = scope.ServiceProvider.GetRequiredService <AppDbContext>();
                DbObjects.Initial(context);
            }
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStatusCodePages();
            app.UseStaticFiles();
            app.UseSession();
            app.UseRouting();
            app.UseMvc(routes => {
                routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
                routes.MapRoute(name: "categoryFilter", template: "laptop/{action}/{category?}", defaults: new { Controller = "laptop", action = "list" });
                routes.MapRoute(name: "Order", template: "order/{action=Checkout}");
            });


            using (var scope = app.ApplicationServices.CreateScope())
            {
                AppDbContext content = scope.ServiceProvider.GetRequiredService <AppDbContext>();
                DbObjects.Initial(content);
            }
        }
Esempio n. 3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseDeveloperExceptionPage();
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            //app.UseMvcWithDefaultRoute();

            app.UseRouting();
            app.UseSession();

            // set up the middleware components that implement the security policy
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseStatusCodePages(); // For Pages with codes 404, 200 etc..


            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute("catpage",
                                             "{category}/Page{productPage:int}",
                                             new { Controller = "Product", action = "List" });

                endpoints.MapControllerRoute("page", "Page{productPage:int}",
                                             new { Controller = "Product", action = "List", productPage = 1 });

                endpoints.MapControllerRoute("category", "{category}",
                                             new { Controller = "Product", action = "List", productPage = 1 });

                endpoints.MapControllerRoute("pagination",
                                             "Products/Page{productPage}",
                                             new { Controller = "Product", action = "List", productPage = 1 });



                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");

                endpoints.MapDefaultControllerRoute();

                endpoints.MapRazorPages(); // registers Razor Pages as endpoints that the URL routing system can use to handle requests.


                endpoints.MapBlazorHub(); // registers the Blazor middleware components
                endpoints.MapFallbackToPage("/admin/{*catchall}", "/Admin/Index");
                // Addition is to finesse the routing system to ensure that Blazor works seamlessly with the rest of  the application.
            });


            DbObjects.Initial(app);
            DbIdentityObjects.EnsurePopulated(app);



            /*
             * using (var scope = app.ApplicationServices.CreateScope())
             * {
             *  ApplicationDbContext context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
             *  DbObjects.Initial(context);
             * }
             *
             */
        }