我正在将一些MVC代码移植到Web API,并且需要更新我的自定义ModelValidatorProviders。似乎我的验证器可以保持基本不变,只需要继承System.Web.Http.Validation命名空间。
我无法弄清楚如何将提供程序添加到Web API中。在使用MVC时,我只需将以下内容添加到global.asax中:
我无法弄清楚如何将提供程序添加到Web API中。在使用MVC时,我只需将以下内容添加到global.asax中:
ModelValidatorProviders.Providers.Add(new CustomModelValidatorProvider());
我如何在Web API中使用自定义提供程序?