To consist of the back button page in MVC

Asked

Viewed 99 times

1

I have a web application . net mvc of satisfaction search, where the user preserves all the data and clicks the button to finish. The system records the survey data and redirects it to another page and sends a message that is finished. However the users click back, so the page comes back and the data is all filled and click again on finish. But the system is recording everything again. I could consist of recording the data, but I would like to know if there is any function to not allow it to go back to page, or.. when returning I can validate if the search has already been filled.

  • Please see [Ask]. Add a minimal and verifiable example, the way it is is not very intuitive.

1 answer

2

You cannot control the behavior of coming back from the browser. This is for security reasons.

What you can do to solve your problem is the following:

  • If users are authenticated in the system, that is, have a username and password (or log in through social network profiles), you can associate the search response to the user. This way you can guarantee at most a complete survey per person. You can even reject a new fill-in if one already exists for the logged-in user;

  • if users are not authenticated, generate a random token in the user session (something like Session["tokenPesquisaSatisfacao"] = algumaStringAleatoria). Put the token in a type control hidden on the page where questions are answered. Store the token along with the answer in the database. If the user returns in the browser, he will get the same token. Then it will be enough not to allow the saving of the answers if there is already a survey answered with the same token.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.