How to use FormHelper and FluentValidation in .netcore 6 razor pages
18:19 30 Jul 2022

I am moving away from mvc to razor pages but can't seem to find my way around with the validation using fluent validator and FormHelper.

Normally with the mvc pattern

[FormValidator]
Public async Task submitFormAction()
{
    // do something 
    return View();
}

With Razor page

 public class AddModel : PageModel
 {
     public void OnGet()
     {

     }
 
     // 'FormValidator' cannot be applied to razor page handler
     // method it may be applied to either Razor page model or
     // applied globally
     [FormValidator]
     public async Task OnPostAsync()
     {
         
     }
 }
c# asp.net-core razor asp.net-core-6.0