小编Ray*_*Ray的帖子

ASP.NET Core 3 没有为该方案注册登录管理器

我一直在尝试将 Identity Server 4 合并到我的 ASP.NET Core 3 应用程序中,但不断收到以下错误:

没有为方案“Identity.Application”注册登录身份验证处理程序。

注册的登录方案有: Cookie。你忘记打电话了吗AddAuthentication().AddCookies("Identity.Application",...)?我不确定这个错误是什么意思。

我查看了这个SO问题,这篇(在ASP.NET Core中使用特定方案授权) MS .NET文章以及其他几篇文章,但没有一个有帮助。

我的Startup.cs

public void ConfigureServices(IServiceCollection services)
{
    var appSettingsSection = Configuration.GetSection("AppSettings");
    services.Configure<AppSettings>(appSettingsSection);

    var appSettings = appSettingsSection.Get<AppSettings>();
    var key = Encoding.ASCII.GetBytes(appSettings.Secret);

    services
        .AddAuthentication(x =>
        {
            x.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
        })
        .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme) // , opt => opt.LoginPath = "/Identity"
        .AddJwtBearer(opt =>
        {
            opt.RequireHttpsMetadata = false;
            opt.SaveToken = true;
            opt.TokenValidationParameters = new TokenValidationParameters
            {
                ValidateIssuerSigningKey = true,
                IssuerSigningKey = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net identityserver4

5
推荐指数
1
解决办法
3351
查看次数

React Hook useState 不更新 UI

我是 React Hooks 的新手,我正在尝试使用以下代码更新购物车中的数量;

import React, { useState, useEffect } from "react";
import cookie from "react-cookies";
import CheckoutItems from "./CheckoutItems";
import restHelper from "../../shared/RestHelper";

const Checkout = () => {
    const [cart, setCart] = useState(null);

    useEffect(() => {
        const cartId = cookie.load("RbCartId");

        if (cartId){
            (async () => {
                const cart = await restHelper.getUserCart(cartId);
                setCart(cart);
            })();
            }
    }, []);

    const handleQtyUpdate = (evt, id) => {
        let _cart = cart;
        let items = _cart.cartItems.filter(x => x.id === id);
        let cartItem = …
Run Code Online (Sandbox Code Playgroud)

reactjs react-hooks

2
推荐指数
1
解决办法
3943
查看次数

标签 统计

asp.net ×1

c# ×1

identityserver4 ×1

react-hooks ×1

reactjs ×1