Exemplo n.º 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)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");

                // redirect http request to https with 301 status code
                var options = new RewriteOptions().AddRedirectToHttpsPermanent();
                app.UseRewriter(options);
            }

            app.UseImageResize();
            app.UseStaticFiles();
            app.UseStatusCodePages();
            app.UseIdentity();
            app.UseSession();
            app.UseVisitorCounter();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areaRoute",
                    template: "{area:exists}/{controller}/{action}/{id?}",
                    defaults: new { controller = "Dashboard", action = "Index" });

                routes.MapRoute(
                    name: "productInfo",
                    template: "Product/{seo}",
                    defaults: new { controller = "Home", action = "ProductInfo" });

                routes.MapRoute(
                    name: "category",
                    template: "Category/{category}",
                    defaults: new { controller = "Home", action = "ProductCategory" });

                routes.MapRoute(
                    name: "manufacturer",
                    template: "Manufacturer/{manufacturer}",
                    defaults: new { controller = "Home", action = "ProductManufacturer" });

                routes.MapRoute(
                    name: "productSearch",
                    template: "search/{name?}",
                    defaults: new { controller = "Home", action = "ProductSearch" });

                routes.MapRoute(
                    name: "create review",
                    template: "CreateReview/{id}",
                    defaults: new { controller = "Home", action = "CreateReview" });

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

            // apply migration
            SampleDataProvider.ApplyMigration(app.ApplicationServices);

            // seed default data
            SampleDataProvider.Seed(app.ApplicationServices, Configuration);
        }
Exemplo n.º 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)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("Home/Error");
                var options = new RewriteOptions().AddRedirectToHttpsPermanent();
                // 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.UseImageResize();
            app.UseStatusCodePages();
            app.UseHttpsRedirection();
            app.UseAuthentication();
            app.UseSession();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            //            app.UseVisitorCounter();

            app.UseMvc();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areaRoute",
                    template: "{area:exists}/{controller}/{action}/{id?}",
                    defaults: new { controller = "Dashboard", action = "Index" });

                routes.MapRoute(
                    name: "productInfo",
                    template: "Product/{seo}",
                    defaults: new { controller = "Home", action = "ProductInfo" });

                routes.MapRoute(
                    name: "category",
                    template: "Category/{category}",
                    defaults: new { controller = "Home", action = "ProductCategory" });

                routes.MapRoute(
                    name: "manufacturer",
                    template: "Manufacturer/{manufacturer}",
                    defaults: new { controller = "Home", action = "ProductManufacturer" });

                routes.MapRoute(
                    name: "productSearch",
                    template: "search/{name?}",
                    defaults: new { controller = "Home", action = "ProductSearch" });

                routes.MapRoute(
                    name: "create review",
                    template: "CreateReview/{id}",
                    defaults: new { controller = "Home", action = "CreateReview" });

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

            // apply migration
            SampleDataProvider.ApplyMigration(app.ApplicationServices);

            // seed default data

            SampleDataProvider.Seed(app.ApplicationServices, Configuration);
        }