Никакие обработчики аутентификации выхода не зарегистрированы ядро ​​asp.net - PullRequest
0 голосов
/ 01 ноября 2019

Следуя старому учебнику asp.net и пытаясь использовать ядро ​​asp.net вместо этого, я иду. Я отлаживаю свое приложение и захожу по ссылке входа в систему, и я столкнулся с этой ошибкой. Может кто-нибудь помочь решить?

    An unhandled exception occurred while processing the request.
    InvalidOperationException: No sign-out authentication handlers are 
    registered. Did you forget to call 
    AddAuthentication().AddCookies("Identity.External",...) 
Microsoft.AspNetCore.Authentication.AuthenticationService.SignOutAsync(HttpContext context, string scheme, AuthenticationProperties properties)

Ошибка в коде здесь:

await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);

В середине этого блока.

            ModelState.AddModelError(string.Empty, ErrorMessage);
        }
        returnUrl = returnUrl ?? Url.Content("~/");
        // Clear the existing external cookie to ensure a clean login process
        await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
        ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
        ReturnUrl = returnUrl;
    }

Startup.cs выглядиткак это:

public void ConfigureServices(IServiceCollection services)
        {
            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddDbContext<GigHubContext>(options =>
                options.UseSqlServer(
                    Configuration.GetConnectionString("GigHubContextConnection")));

            services.AddIdentityCore<GigHubUser>()
                .AddEntityFrameworkStores<GigHubContext>()
                .AddDefaultTokenProviders()
                .AddDefaultUI();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app, 
            IHostingEnvironment env, 
            UserManager<GigHubUser> userManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();

                //gigHubContext.Database.EnsureDeleted();
                //gigHubContext.Database.Migrate();

                // add db lookups
                //DbDataInitializer.SeedGenres(gigHubContext);
                //DbDataInitializer.SeedUsers(userManager);
            }
            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.UseCookiePolicy();
            app.UseAuthentication();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...