我正在尝试通过实现提供用户身份验证UserNamePasswordValidator.我已经加入Microsoft.IdentityModel和System.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)