小编Leo*_*Leo的帖子

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

我正在尝试通过实现提供用户身份验证UserNamePasswordValidator.我已经加入Microsoft.IdentityModelSystem.IdentityModel.Tokens.ValidatingIssuerNameRegistry的NuGet包.我正在使用.Net framework 4.5.2,但是当我UserNamePasswordValidator在我的类中实现UserAuthentication"类型或命名空间名称选择器在命名空间中不存在System.IdentityModel(你是否缺少一些引用)时,我得到并且错误." 我用Google搜索了但无法找到解决方案,我错过了什么吗?下面是我的UserAuthentication班级

 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");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

.net c# authentication

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

标签 统计

.net ×1

authentication ×1

c# ×1