ValidationAttribute (サーバー側でのみ機能するリモート検証用)を作成しようとしていますが、 IsValid メソッド内で、url ルート値から url を解決する必要があります。これが私の初期設定です:
public class ServerSideRemoteAttribute : ValidationAttribute {
public string Controller { get; set; }
public string Action { get; set; }
public object RouteValues { get; set; }
public ServerSideRemoteAttribute(string controller, string action) {
this.Controller = controller;
this.Action = action;
}
public ServerSideRemoteAttribute(string controller, string action, object routeValues) {
this.Controller = controller;
this.Action = action;
this.RouteValues = routeValues;
}
protected override ValidationResult IsValid(object value, ValidationContext validationContext) {
//Here I need to resolve the url in order to make a call to that controller action and get the JSON result back
return base.IsValid(value, validationContext);
}
}
何かご意見は?