Asp.Net 应用服务验证时引发样板异常
本文关键字:异常 Net 应用服务 验证 Asp | 更新日期: 2023-09-27 18:30:23
休 Asp.Net 样板文档,我可以看到当模型无效时会抛出异常:
/// <summary>
/// Validates the method invocation.
/// </summary>
public void Validate()
{
if (_parameters.IsNullOrEmpty())
{
//Object has no parameter, no need to validate.
return;
}
if (_parameters.Length != _arguments.Length)
{
throw new Exception("Method parameter count does not match with argument count!");
}
for (var i = 0; i < _parameters.Length; i++)
{
Validate(_parameters[i], _arguments[i]);
}
if (_validationErrors.Any())
{
throw new AbpValidationException("Method arguments are not valid! See ValidationErrors for details.") { ValidationErrors = _validationErrors };
}
foreach (var argument in _arguments)
{
Normalize(argument); //TODO@Halil: Why not normalize recursively as we did in validation.
}
}
Asp.Net 样板核心中是否有替代方法来更改此方法?
提前谢谢你。
ABP只有在实现IValidate时才验证输入。如果您不想验证它,请不要实现此接口,仅此而已。