The ASP.NET ViewState function can sometimes be a double-edged sword. I rely on this on most of my projects and greatly speeds up development.
My problem is that sometimes users will try to refresh the page, which will lead to the loss of the view state, otherwise the user may want to add a bookmark to the page, but when the view state is returned.
In modern browsers, a silly dialog will be displayed when the user tries to refresh the page that is the result of a POST operation (for example, asp postback), which is generally undesirable.
Interestingly, their way to continue using ViewState and the postback model, but without the drawback of the update dialog box. (and, if possible, write down the page.)
An example of what I can do is to have a page with entries and checkboxes next to them, the user has the opportunity to check all the entries that they want to delete, and then click the delete button. After the user clicks on deletion, the analyzes are analyzed on the server, and on the new page all the records that were selected using the confirmation button confirm are displayed. Now, if the user clicks on the update, he receives this stupid box to confirm whether they want to send messages or not.
I understand that ViewState is the result of using the Post Back model, which means that most asp.net pages are the result of the POST operation, but I'm wondering if there are any ways to use it.
Workarounds that I thought might work:
In the Page_Unload event, save the viewstate in a session with a unique identifier and redirect the user to the same page with a unique identifier as a parameter of the query string, after the page loads with a unique identifier in the URL, the viewstate is loaded from the viewport and entered on the current page . This method will allow the user to refresh the page and always get the same results.
PS I understand that I can use Response.Redirect() and / or query strings, but I want to use the simplicity of ViewState