开发者

Can MVC UpdateModel use Enterprise Library VAB?

开发者 https://www.devze.com 2023-02-23 06:46 出处:网络
...or should I say, what\'s the cleanest way to use Enterprise Library 5 VAB with MVC? I currently use the form:

...or should I say, what's the cleanest way to use Enterprise Library 5 VAB with MVC?

I currently use the form:

ActionResult Save(int id, FormCollection form)
{
   SomeModel model = somehowgetbyid(id);

   UpdateModel(model);

   somehowvalidate(model);

   if(ModelState.IsValid)
   {

etc...

Can VAB decorated classes be validated automagically by updatemodel, or do I get the validator manually and validate it aft开发者_开发知识库er that call? Or are there even better ways?


Here you have nice example of creating a ModelValidatorProvider with Enterprise Library VAB (by Brad Wilson):

  • http://bradwilson.typepad.com/blog/2009/10/enterprise-library-validation-example-for-aspnet-mvc-2.html

It will allow you to use it in any way you want (implicit validation of action parameters or explicit calls to UpdateModel/TryUpdateModel)


It seems that I didn't need to do anything. MVC picks up the VAB attributes by itself. This is for Enterprise Library 5.0.

Wow!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号