开发者

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();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜