1

I'm trying to write a simple page with form in an ASP.NET Core 7 web app with Razor pages. I'm facing a problem while reloading that page.

The previous submission is happening again while reloading. How to prevent form submission while page reload in Razor pages (not MVC)?

In "classic" ASP.NET, I as able to use the IsPostback property to prevent these issues, but in Razor pages, I am unable to use it.

2
  • Could you add some code showing what you did so far ? If you added minimal reproducible example, it would be easier to tell. I'm not sure, at this stage. Commented May 11, 2023 at 5:33
  • Use the Post-Redirect-Get pattern to prevent duplicate form submission: en.wikipedia.org/wiki/Post/Redirect/Get Commented May 11, 2023 at 15:29

1 Answer 1

0

Try to use the RedirectToPage method: In your POST handler, after processing the form submission, use the RedirectToPage method to redirect the user to the corresponding GET handler.

return RedirectToPage("Index");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.