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 SinghRank #66 · 26.2K reputationPosted Jun 14, 2021, 1:24 AM EDT
Marius VasileRank #785 · 2.9K reputationPosted Jun 14, 2021, 12:52 AM EDT
Marius VasileRank #785 · 2.9K reputationPosted Jun 14, 2021, 1:14 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 14, 2021, 12:47 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 14, 2021, 1:08 AM EDT
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 VasileRank #785 · 2.9K reputationPosted Jun 14, 2021, 1:21 AM EDT
Marius VasileRank #785 · 2.9K reputationPosted Jun 14, 2021, 1:27 AM EDT