I'm trying to provide user authentication by implementing UserNamePasswordValidator
. I have added Microsoft.IdentityModel
and System.IdentityModel.Tokens.ValidatingIssuerNameRegistry
nuget packages.
I'm getting and error when I implement UserNamePasswordValidator
in my class UserAuthentication
saying
The type or namespace name Selectors does not exist in namespace
System.IdentityModel
(are you missing some reference).
Why is this failing?
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");
}
}
}
Adding the nuget package is not enough (and also in your case, unnecessary), you need to reference the dll in your project. Look for the References list in the solution explorer.
Right click -> Add Reference -> type System.IdentityModel to search box -> select the right dll -> click OK -> Good to go
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With