我在南希示例應用程序和與請求驗證的問題。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 –