Redirect during validation
Sometimes inside FluentValidation validator I need to make redirect if state is incorrect (for example, I find that being deleted entity already does not exist and I redirect to the list of entities). Is validator a right place for this kind of logic? If yes, how can I RedirectToAction, RedirectToRoute,开发者_如何转开发 etc. from validator?
No, validation shouldn't control UI flow.
Normally something like this is appropriate inside of your controller:
if( !ModelState.IsValid )
return RedirectToAction();
精彩评论