我有一个表单,我正在尝试向电子邮件字段添加自定义验证,以阻止禁止的域。我在Sitecore中创建了验证项,并将其添加到我的字段中:
然后我在项目中创建了相应的类:
namespace Example.Library.WebForms.Validators
{
public class EmailValidation : FormCustomValidator
{
public EmailValidation()
{
this.ServerValidate += this.ValidateEmailAddress;
}
private void ValidateEmailAddress(object source, ServerValidateEventArgs args)
{
var blacklistFolder = Sitecore.Context.Database.GetItem(exampleConstants.exampleBlacklistFolder);
var domains = blacklistFolder.Axes.GetDescendants().Select(x => x.GlassCast<IRestricted_Domain>());\
var email = args.Value;
foreach (var dom in domains)
{
var domain = dom.Domain;
if (email.ToLower().EndsWith(domain.ToLower()))
{
args.IsValid = false;
}
}
}
}
}
但是它似乎没有做任何事情,并且当我调试并附加到ValidateEmailAddress方法时,它永远不会命中它。我想念什么?
编辑:我将程序集从Example.Library更改为Example.Library.dll,但仍然没有成功。