0
在Web API或ASP.NET MVC應用程序,我可以做加全球驗證過濾器 -驗證篩選特定的控制器
GlobalConfiguration.Configuration.Filters.Add(new ModelValidationFilterAttribute());
和
public class ModelValidationFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(HttpActionContext actionContext)
{
if (actionContext.ModelState.IsValid == false)
{
actionContext.Response = actionContext.Request.CreateErrorResponse(HttpStatusCode.BadRequest, actionContext.ModelState);
}
}
}
但我想有很多驗證適用於我選擇的控制器的過濾器?