Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的模型上有很多 MVC 验证属性。当 defaultModelBinder 在提交时绑定我的模型时,一切都很好。但是,我需要创建一个自定义模型绑定器。我想继续使用我的验证属性。我可以吗?如果是这样,怎么做?
我不确定这是否可能,但我可以说的一件事是,如果可能的话,默认模型绑定器的扩展点不会让它很容易被发现。我一天花了几个小时试图让这个工作无济于事。
您可以使用控制器的 TryValidateModel() 方法来代替使其工作。