-1
我試圖通過執行UserNamePasswordValidator
來提供用戶身份驗證。我添加了Microsoft.IdentityModel
和System.IdentityModel.Tokens.ValidatingIssuerNameRegistry
nuget包。我正在使用.Net framework 4.5.2
,但是我在執行UserNamePasswordValidator
時遇到錯誤UserAuthentication
「(缺少某些引用)」類型名稱或命名空間名稱選擇器不存在。我已經搜索了它,但無法找到解決方案,我錯過了什麼?下面是我的UserAuthentication
類找不到名稱空間System.IdentityModel.Services
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");
}
}
}
感謝您的幫助,它的工作。 – Leo