示例#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();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

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

            app.UseRouting();

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

            var options = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >();

            app.UseRequestLocalization(options.Value);

            app.UseSession();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapDefaultControllerRoute();
                endpoints.MapRazorPages();
            });

            IdentitySeedData.EnsurePopulated(app);
        }
示例#2
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseStatusCodePagesWithRedirects("/Error/{0}");
                app.UseHsts();
            }
            app.UseStatusCodePages();
            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSession();
            app.UseAuthentication();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
            SeedData.EnsurePopulated(app);
            IdentitySeedData.EnsurePopulated(app);
            ApplicationNameRepository.SeedData(app);
        }
示例#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)
        {
            app.UseDeveloperExceptionPage();
            app.UseStatusCodePages();
            app.UseStaticFiles();
            app.UseSession();
            app.UseRouting();

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

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

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

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

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

                endpoints.MapDefaultControllerRoute();
                endpoints.MapRazorPages();
            });

            SeedData.EnsurePopulated(app);
            IdentitySeedData.EnsurePopulated(app);
        }
示例#4
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseStatusCodePages();
            app.UseStaticFiles();
            app.UseSession();
            app.UseIdentity();

            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "1",
                                template: "{controller}/{action}/{category}/{pageNum}/{sortOrder?}",
                                defaults: new { controller = "Notice", action = "List" },
                                constraints: new { pageNum = new IntRouteConstraint() });

                routes.MapRoute(name: "2",
                                template: "{controller}/{action}/{pageNum?}/{sortOrder?}",
                                defaults: new { controller = "Notice", action = "List" }
                                );
            });
            IdentitySeedData.EnsurePopulated(app);
        }
示例#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, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

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

            app.UseStaticFiles();
            app.UseIdentity();

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

            IdentitySeedData.EnsurePopulated(app);
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();
            app.UseAuthentication();
            app.UseSession();
            IdentitySeedData.EnsurePopulated(app);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
示例#7
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.IsProduction())
            {
                app.UseExceptionHandler("/error");
            }
            else
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }
            app.UseStaticFiles();
            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute("pagination", "Rooms/Page{roomPage::regex(^[1-9]\\d*$)=1}",
                                             new { Controller = "Home", action = "Index" });
                endpoints.MapControllerRoute("roominfo", "Room{QuestId}",
                                             new { Controller = "Home", action = "Room" });
                endpoints.MapDefaultControllerRoute();
                endpoints.MapRazorPages();
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/admin/{*catchall}", "/Admin/Index");
            });
            SeedData.EnsurePopulated(app);
            IdentitySeedData.EnsurePopulated(app);
        }
示例#8
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();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();

            app.UseAuthorization();

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

            IdentitySeedData.EnsurePopulated(app);
        }
示例#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)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseStatusCodePages();
            app.UseStaticFiles();
            app.UseSession();
            app.UseAuthentication();
            app.UseMvc(routes =>
            {
                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: "default",
                    template: "{controller=Product}/{action=List}/{id?}");
            });

            SeedData.EnsurePopulated(app);
            IdentitySeedData.EnsurePopulated(app);

            app.Run(async(context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
        }
示例#10
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseAuthentication();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
                routes.MapRoute(name: "Account", template: "{controller=Account}/{action=Index}/{id?}");
                routes.MapRoute(name: "Admin", template: "{controller=Admin}/{action=Index}/{id?}");
                routes.MapRoute(name: "AdminHome", template: "{controller=AdminHome}/{action=Index}/{id?}");
                routes.MapRoute(name: "AdminUser", template: "{controller=AdminUser}/{action=Index}/{id?}");
            });
            SeedData.EnsurePopulated(app);
            IdentitySeedData.EnsurePopulated(app);
        }
示例#11
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
     app.UseDeveloperExceptionPage();
     app.UseStatusCodePages();
     app.UseStaticFiles();
     app.UseAuthentication();
     //app.UseMvcWithDefaultRoute();
     app.UseMvc(routes =>
     {
         routes.MapRoute(
             name: null,
             template: "Page{homePage:int}",
             defaults: new { controller = "Home", action = "Index" }
             );
         //routes.MapRoute(
         //   name: null,
         //   template: "category",
         //   defaults: new { controller = "Home", action = "Index", productPage = 1 }
         //   );
         //routes.MapRoute(name: "Paging", template: "Product/Page{productPage}", defaults: new { Controller = "Product", Action = "List" }) ;
         routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
     });
     SeedData.EnsurePopulated(app);
     IdentitySeedData.EnsurePopulated(app);
 }
示例#12
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.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapDefaultControllerRoute();

                endpoints.MapRazorPages();

                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/admin/{*catchall}", "/Admin/Index");
            });

            SeedData.EnsurePopulated(app);
            IdentitySeedData.EnsurePopulated(app);
        }
示例#13
0
 public AccountController(UserManager <IdentityUser> userMgr,
                          SignInManager <IdentityUser> signInMgr)
 {
     userManager   = userMgr;
     signInManager = signInMgr;
     IdentitySeedData.EnsurePopulated(userMgr).Wait();
 }
示例#14
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.IsProduction())
            {
                app.UseExceptionHandler("/error");
            }
            else
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }
            app.UseDeveloperExceptionPage();
            app.UseStatusCodePages();
            app.UseStaticFiles();
            app.UseSession();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute("catpage", "{category}/Page{productPage:int}", new { Controller = "Home", action = "Index" });
                endpoints.MapControllerRoute("page", "Page{productPage:int}", new { Controller = "Home", action = "Index", productPage = 1 });
                endpoints.MapControllerRoute("category", "{category}", new { Controller = "Home", action = "Index", productPage = 1 });
                endpoints.MapControllerRoute("Pagination", "Products/Page{productPage}", new { Controller = "Home", action = "Index", productPage = 1 });
                endpoints.MapDefaultControllerRoute();
                endpoints.MapRazorPages();
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/admin/{*catchall}", "/Admin/Index");
            });
            SeedData.EnsurePopulated(app);
            IdentitySeedData.EnsurePopulated(app);
        }
示例#15
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.IsProduction())
            {
                app.UseExceptionHandler("/error");
            }
            else
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }

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

            app.UseRouting();

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

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapDefaultControllerRoute();
                endpoints.MapRazorPages();
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/admin/{*catchall}", "/Admin/Index");
            });
            IdentitySeedData.EnsurePopulated(app);
        }
示例#16
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.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

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

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

            IdentitySeedData.EnsurePopulated(app);
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                //app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }

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

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

            SeedData.EnsurePopulated(app);
            IdentitySeedData.EnsurePopulated(app);
        }
示例#18
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)
        {
            app.UseDeveloperExceptionPage();
            app.UseStatusCodePages();
            app.UseStaticFiles();
            app.UseSession();
            app.UseIdentity();
            app.UseMvc(routes =>
            {
                routes.MapRoute(name: null,
                                template: "{category}/Page{page:int}",
                                defaults: new { controller = "Product", action = "List" }
                                );
                routes.MapRoute(
                    name: null,
                    template: "Page{page:int}",
                    defaults: new { controller = "Product", action = "List", page = 1 }
                    );
                routes.MapRoute(
                    name: null,
                    template: "{category}",
                    defaults: new { controller = "Product", action = "List", page = 1 }
                    );
                routes.MapRoute(
                    name: null,
                    template: "",
                    defaults: new { controller = "Product", action = "List", page = 1 });
                routes.MapRoute(name: null, template: "{controller}/{action}/{id?}");
            });

            SeedData.EnsurePopulated(app);
            IdentitySeedData.EnsurePopulated(app);
        }
示例#19
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    var roleManager     = scope.ServiceProvider.GetService <RoleManager <IdentityRole> >();
                    var userManager     = scope.ServiceProvider.GetService <UserManager <AppUser> >();
                    var identityContext = scope.ServiceProvider.GetRequiredService <AppIdentityContext>();
                    var productContext  = services.GetRequiredService <ProductContext>();

                    identityContext.Database.Migrate();
                    IdentitySeedData.EnsurePopulated(identityContext, roleManager, userManager);

                    productContext.Database.Migrate();
                    ProductSeedData.EnsurePopulated(productContext, identityContext);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred seeding the DB.");
                }
            }

            host.Run();
        }
示例#20
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.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseStaticFiles();

            //enabling sessions
            app.UseSession();

            //enabling identity
            app.UseIdentity();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "Error",
                    template: "Error",
                    defaults: new { controller = "Error", action = "Error" }
                    );
                routes.MapRoute(
                    name: null,
                    template: "{category}/Page{page:int}",
                    defaults: new { controller = "Product", action = "List" }
                    );

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

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

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

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

            SeedData.EnsurePopulated(app);
            IdentitySeedData.EnsurePopulated(app);
        }
示例#21
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.UseRouting();

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

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    "Dashboard",
                    �������������������� "/",
                    ��������������������new {
                    Controller = "Dashboard", action = "Index"
                }
                    );
                ����������������endpoints.MapControllerRoute(
                    "catpage",
                    �������������������� "{category}/Page{partPage:int}",
                    ��������������������new {
                    Controller = "Parts", action = "Index"
                }
                    );
                ����������������endpoints.MapControllerRoute(
                    "page",
                    "Page{partPage:int}",
                    ��������������������new {
                    Controller = "Parts", action = "Index", partPage = 1
                }
                    );
                ����������������endpoints.MapControllerRoute(
                    "category",
                    "{category}",
                    ��������������������new {
                    Controller = "Parts", action = "Index", partPage = 1
                }
                    );
                ����������������endpoints.MapControllerRoute(
                    "pagination",
                    �������������������� "Parts/Page{partPage}",
                    ��������������������new {
                    Controller = "Parts", action = "Index", partPage = 1
                }
                    );
                endpoints.MapDefaultControllerRoute();
                endpoints.MapRazorPages();
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/admin/{*catchall}", "/Admin/Index");
            });
            SeedData.EnsurePopulated(app);
            IdentitySeedData.EnsurePopulated(app);
        }
示例#22
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(LogLevel.Debug);
            loggerFactory.AddDebug();

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

            app.UseStaticFiles();
            app.UseSession();
            app.UseIdentity();

            app.UseGoogleAuthentication(new GoogleOptions
            {
                ClientId     = Configuration["Authentication:Google:ClientId"],
                ClientSecret = Configuration["Authentication:Google:ClientSecret"]
            });
            app.UseClaimsTransformation(LocationClaimsProvider.AddClaims);

            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "Error", template: "Error",
                                defaults: new { controller = "Error", action = "Error" });

                routes.MapRoute(
                    name: null,
                    template: "{status}/Page{page:int}",
                    defaults: new { controller = "Task", action = "List" }
                    );

                routes.MapRoute(
                    name: null,
                    template: "Page{page:int}",
                    defaults: new { controller = "Task", action = "List", page = 1 }
                    );

                routes.MapRoute(
                    name: null,
                    template: "{status}",
                    defaults: new { controller = "Task", action = "List", page = 1 }
                    );

                routes.MapRoute(
                    name: null,
                    template: "",
                    defaults: new { controller = "Task", action = "List", page = 1 });

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

            IdentitySeedData.EnsurePopulated(app);
        }
示例#23
0
 public AccountController(UserManager <ApplicationUser> userMgr,
                          SignInManager <ApplicationUser> signInMgr, RoleManager <ApplicationRole> roleMngr)
 {
     userManager   = userMgr;
     signInManager = signInMgr;
     roleManager   = roleMngr;
     IdentitySeedData.EnsurePopulated(userMgr, roleMngr).Wait();       //only for enviroment = production
 }
示例#24
0
        public AccountController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, RoleManager <IdentityRole> roleManager)
        {
            this.userManager   = userManager;
            this.signInManager = signInManager;
            this.roleManager   = roleManager;

            IdentitySeedData.EnsurePopulated(userManager, roleManager).Wait();
        }
示例#25
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, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseStaticFiles();
            app.UseSession();
            app.UseAuthentication();//UseIdentity(); - obsolete
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "Error",
                    template: "Error",
                    defaults: new { Controller = "Error", Action = "Error" }
                    );
                routes.MapRoute(
                    name: null,
                    template: "{category}/Page/{page:int}/",
                    defaults: new { Controller = "Product", Action = "List" }
                    );
                routes.MapRoute(
                    name: null,
                    template: "Page/{page:int}/",
                    defaults: new { Controller = "Product", Action = "List", page = 1 }
                    );
                routes.MapRoute(
                    name: null,
                    template: "{category}/",
                    defaults: new { Controller = "Product", Action = "List", page = 1 }
                    );
                routes.MapRoute(
                    name: null,
                    template: "",
                    defaults: new { Controller = "Product", Action = "List", page = 1 }
                    );
                routes.MapRoute(
                    name: null,
                    template: "{controller}/{action}/{id?}/");

                //routes.MapRoute(
                //    name: "pagination",
                //    template: "Products/Page/{page}/",
                //    defaults: new { Controller = "Product", action = "List" });

                //routes.MapRoute(
                //    name: "default",
                //    template: "{controller=Product}/{action=List}/{id?}");
            });
            SeedData.EnsurePopulated(serviceProvider);
            IdentitySeedData.EnsurePopulated(serviceProvider);
        }
示例#26
0
        public AccountController(
            UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager)
        {
            _userManager   = userManager;
            _signInManager = signInManager;

            // Начальное заполнение данными в Production.
            IdentitySeedData.EnsurePopulated(userManager).Wait();
        }
示例#27
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, IdentitySeedData identitySeedData)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            //var options = new RewriteOptions()
            //   .AddRedirectToHttps();

            //app.UseRewriter(options);

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

            app.UseStaticFiles();

            app.UseSession();

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "category",
                    template: "Products/Category/{category}/{productPage}",
                    defaults: new { Controller = "Products", Action = "Index" }
                    );
                routes.MapRoute(
                    name: "pagination",
                    template: "Products/{productPage}",
                    defaults: new { Controller = "Products", Action = "Index" }
                    );
                //routes.MapRoute(
                //   name: "sorting",
                //   template: "Products/{productPage}",
                //   defaults: new { Controller = "Products", Action = "Index" }
                //   );
                routes.MapRoute(
                    name: "cart",
                    template: "Cart",
                    defaults: new { Controller = "Cart", Action = "Index" }
                    );

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

            identitySeedData.EnsurePopulated().Wait();
        }
示例#28
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider services)
 {
     app.UseStatusCodePages();
     app.UseAuthentication();
     app.UseStaticFiles();
     app.UseMvcWithDefaultRoute();
     SeedData.Populate(app);
     IdentitySeedData.EnsurePopulated(app);
 }
示例#29
0
        private static async void InitDB(IServiceProvider service)
        {
            BooksAndGenresSeedData.EnsurePopulated(service);
            await IdentitySeedData.EnsureRoles(service);

            await IdentitySeedData.EnsureMenuElements(service);

            await IdentitySeedData.EnsurePopulated(service);
        }
示例#30
0
        //used in develpment envirenment
        public void ConfigureDevelopment(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            //development
            app.UseDeveloperExceptionPage();
            app.UseBrowserLink();

            app.UseStaticFiles();
            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot/Files/Pictures")),
                RequestPath  = new PathString("/Pictures")
            });
            app.UseStaticFiles(new StaticFileOptions()//烹饪菜品图片文件
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot/Files/Pictures/Dishes")),
                RequestPath  = new PathString("/Dishes")
            });
            app.UseStaticFiles(new StaticFileOptions()//摄影图片文件
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot/Files/Pictures/Albums")),
                RequestPath  = new PathString("/Albums")
            });
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()//文件目录浏览(危险,默认禁止启用)
            {
                FileProvider = new PhysicalFileProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot/Files/Pictures")),
                RequestPath = new PathString("/Pictures")
            });
            app.UseSession();
            app.UseIdentity();
            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "Error", template: "Error", defaults: new { controller = "Error", action = "Error" });
                if (appName == AppName.SportsStroe)
                {
                    routes.MapRoute(name: null, template: "{category}/Page{page:int}", defaults: new { controller = "Product", action = "List" });
                    routes.MapRoute(name: null, template: "Page{page:int}", defaults: new { controller = "Product", action = "List", page = 1 });
                    routes.MapRoute(name: null, template: "{category}", defaults: new { controller = "Product", action = "List", page = 1 });
                    routes.MapRoute(name: null, template: "", defaults: new { controller = "Product", action = "List", page = 1 });
                    routes.MapRoute(name: null, template: "{controller}/{action}/{id?}");
                }
                else
                {
                    routes.MapRoute(name: "areas", template: "{area:exists}/{controller=Home}/{action=Index}");
                    routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
                }
            });
            // Shows UseCors with named policy.
            app.UseCors("AllowSpecificOrigin");
            SeedData.EnsurePopulated(app);
            IdentitySeedData.EnsurePopulated(app);
        }