I am using an asp.net core razor pages web app and I want to prevent using back button and re-submitting same data after a post. Is there a more simpler way than disabling the back button for a specific page or checking data against database?
Loading

Sachin SinghPosted Jun 14, 2021, 5:24 AM
Marius VasilePosted Jun 14, 2021, 5:27 AM
Marius VasilePosted Jun 14, 2021, 5:21 AM
Marius VasilePosted Jun 14, 2021, 5:14 AM
Sachin SinghPosted Jun 14, 2021, 5:08 AM
You are already doing return Page(), which means it will be redirected to the get request, and hence on form resubmission the browser itself will display a warning like do you want to resubmit the form.
If the default behaviour is not working then you will have to use javascript like clearing the form as shown below.
Marius VasilePosted Jun 14, 2021, 4:52 AM
Sachin SinghPosted Jun 14, 2021, 4:47 AM