WCF自定义验证器

时间:2018-04-02 18:59:00

标签: wcf customvalidator

设置CustomValidator时出现以下错误:

无法加载文件或程序集“Ringo.Authentication”或其依赖项之一。系统找不到指定的文件。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IdentityModel.Selectors;
using System.IdentityModel.Tokens;
using Ringo.Utilities;


namespace Ringo.Authentication
{
public class CustomUserNameValidator : UserNamePasswordValidator
{
    public override void Validate(string Username, string Password)
    {
        Accounts account = new Accounts();

        if (account.CheckUserAccount(Username, Password))
        {
            return;
        }

        throw new SecurityTokenException("Accout is Invalid");
    }
}
}


      <serviceCredentials >
        <userNameAuthentication userNamePasswordValidationMode="Custom"  customUserNamePasswordValidatorType="Ringo.Authentication.CustomUserNameValidator, Ringo.Authentication"/>
      </serviceCredentials>

任何帮助都会非常感谢!

1 个答案:

答案 0 :(得分:0)

以下:

<serviceCredentials >
    <userNameAuthentication userNamePasswordValidationMode="Custom"  customUserNamePasswordValidatorType="Ringo.Authentication.CustomUserNameValidator, **Ringo.Authentication**"/>
  </serviceCredentials>

应该是:

      <serviceCredentials >
        <userNameAuthentication userNamePasswordValidationMode="Custom"  customUserNamePasswordValidatorType="Ringo.Authentication.CustomUserNameValidator, **Ringo**"/>
      </serviceCredentials>