我在南希示例应用程序和与请求验证的问题。Nancy和请求验证
我使用FluentValidator与BindAndValidate扩展。因此,例如,我有模式:
public class User
{
public string Name { get; set; }
public int Age { get; set; }
}
而且模块:
Post["/create-user"] = m => this.BindAndValidate<User>());
而且有问题的,如果客户端应用程序调用模块的参数名称:“富,年龄:”一些字符串”, 然后南希抛出异常:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: some-string is not a valid value for Int32. ---> System.FormatException: Input string was not in a correct format.
这里是通过参数异常任何解决方法(“财产年龄是不是在正确的垫子“)?
感谢
看起来像今天这样良好记录在这里https://github.com/NancyFx/Nancy/wiki/Nancy-and-Validation –