Beispiel #1
0
        public override void OnApplicationInitialization(ApplicationInitializationContext context)
        {
            var app = context.GetApplicationBuilder();

            if (context.GetEnvironment().IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseErrorPage();
            }

            app.UseVirtualFiles();

            app.UseSwagger();
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API");
            });

            app.UseAuthentication();
            app.UseAbpRequestLocalization();
            app.UseAuditing();


            app.UseMvcWithDefaultRouteAndArea();

            using (var scope = context.ServiceProvider.CreateScope())
            {
                AsyncHelper.RunSync(async() =>
                {
                    await scope.ServiceProvider
                    .GetRequiredService <IIdentityDataSeeder>()
                    .SeedAsync(
                        "1q2w3E*"
                        );

                    await scope.ServiceProvider
                    .GetRequiredService <IPermissionDataSeeder>()
                    .SeedAsync(
                        RolePermissionValueProvider.ProviderName,
                        "admin",
                        IdentityPermissions.GetAll().Union(MyProjectNamePermissions.GetAll())
                        );
                });
            }
        }
        public override void OnApplicationInitialization(ApplicationInitializationContext context)
        {
            var app = context.GetApplicationBuilder();

            if (context.GetEnvironment().IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseErrorPage();
            }

            app.UseVirtualFiles();

            app.UseSwagger();
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API");
            });

            app.UseAuthentication();
            app.UseAbpRequestLocalization();
            app.UseAuditing();

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

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

            AsyncHelper.RunSync(async() =>
            {
                await context.ServiceProvider
                .GetRequiredService <IIdentityDataSeeder>()
                .SeedAsync(
                    "1q2w3E*",
                    IdentityPermissions.GetAll().Union(MyProjectNamePermissions.GetAll())
                    );
            });
        }