找不到命名空间 System.IdentityModel.Services。

9
我正在尝试通过实现UserNamePasswordValidator来提供用户身份验证。我已添加Microsoft.IdentityModelSystem.IdentityModel.Tokens.ValidatingIssuerNameRegistry nuget包。
当我在我的类UserAuthentication中实现UserNamePasswordValidator时,出现错误,显示:
“类型或命名空间Select的名称在命名空间System.IdentityModel中不存在(您是否缺少某些参考)。”
为什么会出现这种错误?
public class UserAuthentication : System.IdentityModel.Selectors.UserNamePasswordValidator
{
    public override void Validate(string userName, string password)
    {
        try
        {
            if (userName == "test" && password == "test123")
            {
                Console.WriteLine("Authentic User");
            }
        }
        catch (Exception ex)
        {
            throw new FaultException("Unknown Username or Incorrect Password");
        }
    }
}
1个回答

9

仅仅添加 nuget 包是不够的(在您的情况下也是不必要的),您需要在项目中引用该 dll。在解决方案资源管理器中查找"引用"列表。

右键单击 -> 添加引用 -> 在搜索框中键入 System.IdentityModel -> 选择正确的 dll -> 点击确定 -> 就可以了


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接