Consist of the button back page in MVC

1

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

    
asked by anonymous 05.07.2017 / 13:06

1 answer

2

You can not control the behavior of browser back. This is for the sake of security.

What you can do to solve your problem is as follows:

  • If users are authenticated in the system, that is, they have a user name and password (or log in via social profiles), you can associate the search response with the user. So you guarantee at most one search fill per person. You can even reject a new fill if one already exists for the logged in user;

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

05.07.2017 / 13:18