Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            IdentityRegistrar.Register(services);

            AuthConfigurer.Configure(services, _appConfiguration);

            services.AddRazorPages();
            services.AddServerSideBlazor();
            services.AddSignalR();

            services.AddHeadElementHelper(); // <- Add this.
            services.AddHttpClient();
            services.AddSession(options =>
            {
                //记录浏览量会根据session判断用户,默认是1天,所以session时效设置要求在1天以上
                // Set a short timeout for easy testing.
                options.IdleTimeout        = TimeSpan.FromDays(1);
                options.Cookie.HttpOnly    = true;
                options.Cookie.IsEssential = true;
            });

            services.AddAuthorizationCore();
            //    services.AddScoped<AuthenticationStateProvider, IdentityAuthenticationStateProvider>();

            services.AddScoped <IdentityAuthenticationStateProvider>();
            services.AddScoped <AuthenticationStateProvider>(s => s.GetRequiredService <IdentityAuthenticationStateProvider>());

            services.Add52AbpBlazorAuthExceptionHandling(options =>
            {
                options.DefaultRedirectPath      = "/error";
                options.NoLoginRedirectPath      = "/no-login";
                options.NoPermissionRedirectPath = "/no-permission";
            });

            // Configure Abp and Dependency Injection
            return(services.AddAbp <YoyoCmsTemplateWebPublicModule>(
                       // Configure Log4Net logging
                       options => options.IocManager.IocContainer.AddFacility <LoggingFacility>(
                           f => f.UseAbpLog4Net().WithConfig("log4net.config")
                           )
                       ));
        }