How to return either Redirect of the same page with model in Rasor?

28 Views Asked by At

In OnPost method I have two options

  • Success: I need to redirect to view page.
  • Failure: I need to return the same page with filled model to show errors to the user.

What should the handler return? IActionResult, something else? Maybe the whole flow is wrong?

1

There are 1 best solutions below

0
On
if (ModelState.IsValid)
{
    ...
    return LocalRedirect(...);
}
else
{
    ...
    return Page();
}