Leo*_*Leo 2 .net c# authentication
我正在尝试通过实现提供用户身份验证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)
添加nuget包是不够的(在您的情况下也是不必要的),您需要在项目中引用dll.在解决方案资源管理器中查找"引用"列表.
右键单击 - >添加引用 - >键入System.IdentityModel到搜索框 - >选择正确的dll - >单击确定 - >好去
| 归档时间: |
|
| 查看次数: |
3962 次 |
| 最近记录: |