Пример #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,
                              IIdentitySeeder identitySeeder,
                              IDatabaseSeeder databaseSeeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            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.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

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

            identitySeeder.Seed();
            //Identity seeder needs to be run first so roles and admin are seeded
            databaseSeeder.Seed();
        }
Пример #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, IIdentitySeeder identitySeeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages(); // felhantering implementation Florin
            }
            else
            {
                app.UseExceptionHandler("/error.html");
                app.UseStatusCodePagesWithReExecute("/Home/Error", "?statusCode={0}");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseAuthentication();

            //AuthAppBuilderExtensions.UseAuthentication(app);
            app.UseCookiePolicy();

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

                routes.MapRoute(
                    name: "carResultsRoute",
                    template: "/{action=CarPage}/{id:int?}");
            });

            //identitySeeder.CreateAdminAccountIFEmpty();
        }
Пример #3
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IIdentitySeeder identitySeeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseStatusCodePagesWithReExecute("/Error/Error", "?statusCode={0}");
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Account}/{action=Login}/{id?}");
            });

            identitySeeder.CreateAdminAccountIFEmpty();
        }
Пример #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IIdentitySeeder identitySeeder, KingPimDatabaseContext ctx)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages(); // felhantering implementation
            }
            else
            {
                app.UseExceptionHandler("/error.html");
                app.UseStatusCodePagesWithReExecute("/Error/Error", "?statusCode={0}");
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Account}/{action=Login}/{id?}");
            });

            identitySeeder.CreateAdminAccountIFEmpty();
        }
Пример #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IIdentitySeeder identitySeeder)
        {
            RotativaConfiguration.Setup(env);

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

                app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
                {
                    HotModuleReplacement = true,
                    ConfigFile           = Path.Combine(env.ContentRootPath, @"node_modules\@vue\cli-service\webpack.config.js")
                });
            }
            else
            {
                // 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.UseStaticFiles();
            app.UseAuthentication();
            app.UseHttpsRedirection();

            // Routa till MVC-controller om controllen finns
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            // Fallback
            app.MapWhen(x => !x.Request.Path.Value.StartsWith("/api"), builder =>
            {
                builder.UseMvc(routes =>
                {
                    routes.MapSpaFallbackRoute(
                        name: "spa-fallback",
                        defaults: new { controller = "Home", action = "Index" });
                });
            });
            identitySeeder.CreateAdminAccountIFEmpty();
        }
Пример #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext ctx, IIdentitySeeder identitySeeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }
            else
            {
                app.UseExceptionHandler("/error.html");
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseAuthentication();

            app.UseCookiePolicy();
            //app.UseMvcWithDefaultRoute();

            // Add custom route template

            app.UseStatusCodePagesWithReExecute("/errors/{0}");

            app.UseMvc(routes =>
            {
                // -> /bilar/1
                routes.MapRoute(
                    name: "bilar/vehicleId",
                    template: "bilar/{brandName}/{model}/{modelDescription}/{vehicleId:int}",
                    defaults: new { controller = "Home", action = "Vehicle" }
                    );

                // -> /bilar/nya och bilar/begagnade
                routes.MapRoute(
                    name: "bilar/state",
                    template: "bilar/{state}",
                    defaults: new { controller = "Home", action = "Index" }
                    );

                // -> /bilar
                routes.MapRoute(
                    name: "",
                    template: "bilar",
                    defaults: new { controller = "Home", action = "Index" }
                    );

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

            var runIdentitySeed = Task.Run(async() => await identitySeeder.CreateAdminAccountIfEmpty()).Result;

            VehicleSeed.FillIfEmpty(ctx);
        }
Пример #7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext ctx, IIdentitySeeder identitySeeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStaticFiles();

            app.UseAuthentication();

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

                routes.MapRoute(
                    name: "AttributeGroup",
                    template: "{controller=AttributeGroup}/{action=Index}");

                routes.MapRoute(
                    name: "Category",
                    template: "{controller=Category}/{action=Index}");

                routes.MapRoute(
                    name: "Account",
                    template: "{controller=Account}/{action=Index}/{userId?}/{code?}");
            });

            var runIdentitySeed = Task.Run(async() => await identitySeeder.CreateAdminAccountIfEmpty()).Result;

            Seed.FillIfEmpty(ctx);
        }
Пример #8
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext ctx, IIdentitySeeder identitySeeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }
            else
            {
                app.UseExceptionHandler("/error.html");
            }

            app.UseStaticFiles();

            app.UseAuthentication();
            app.UseSession();

            app.UseMvc(routes =>
            {
                // -> /produkter/skruvdragare/sida/1
                routes.MapRoute(
                    name: null,
                    template: "produkter/{selectedCategory}/sida/{page:int}",
                    defaults: new { controller = "Product", action = "List" }
                    );

                // -> /produkter/sida/2
                routes.MapRoute(
                    name: null,
                    template: "produkter/sida/{page:int}",
                    defaults: new { controller = "Product", action = "List", page = 1 }
                    );

                // -> /produkter/skruvdragare
                routes.MapRoute(
                    name: null,
                    template: "produkter/{selectedCategory}",
                    defaults: new { controller = "Product", action = "List", page = 1 }
                    );
                // -> /
                routes.MapRoute(
                    name: null,
                    template: "",
                    //defaults: new { controller = "Product", action = "List", page = 1 }
                    defaults: new { controller = "Home", action = "Index", page = 1 }
                    );

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

            identitySeeder.CreateAdminAccountIfEmpty();

            Seed.FillIfEmpty(ctx);
        }
Пример #9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext ctx, IIdentitySeeder identitySeeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }

            // To get access to the wwwroot files...
            app.UseStaticFiles();

            app.UseCookiePolicy();

            app.UseAuthentication();

            app.UseMvcWithDefaultRoute();

            app.UseSession();

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

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

                routes.MapRoute(
                    name: "Vehicles/vehicleId",
                    template: "Vehicle/{Brand}/{Model}/{ModelDescription}/{Id:int}",
                    defaults: new { controller = "Vehicle", action = "Index" }
                    );
            });

            var runIdentitySeed = Task.Run(async() => await identitySeeder.CreateAdminAccountIfEmpty()).Result;

            Seed.FillIfEmpty(ctx);
        }