Umbraco SurfaceController prevent resubmit warning (err_cache_miss) on back or forward button

I thought I’d post this here, I’m posting a form to a surface controller and want to prevent a resubmit warning (err_cache_miss) on back or forward button actions. These are calculators, and it doesn’t matter if the forms are resubmitted.

An Umbraco 8 site I’ve seen doesn’t have this issue, but an Umbraco 13 site does. Is this because 13 uses .NET Core?

As far as my options, I think these are them:

  1. Use RedirectToCurrentUmbracoPage() and store result model as json in TempData. Downside is once tempdata is consumed once, it is gone, so back and forward would not render the results
  2. Use RedirectToCurrentUmbracoPage() and store result model as json in Session, not doing this though, Session was not meant to store large json objects
  3. Convert forms with js to a GET request, change the url when posted (querystrings). May not be feasible, the forms are complicated.
  4. Convert the forms to ajax submissions, take over browser state with js replaceState. This may be best, I can read from the ajax result and populate the page with results after a post in-browser.

Is there any other option I’m missing? This seems overkill but I don’t know of some other means of bypassing the browser resubmit warning.

I think you have what I think are the most feasible options .. what about having some JavaScript intercept the butuun submit and disabling the button preventing multiple submits .. but I think that part of one of your solutins

Sounds like the PRG pattern of old might help.. though comes with caveats in .net core…

So this is actually a question about persisting form state?

How large are we talking?

Is the server not storing the submissions? Why POST at all? Why not do the calculations and handle persistence entirely in JS?

return CurrentUmbracoPage();
persists the form state and modelState? really for serverside validation but might be hackable for your purposes?

actually .. i hadn’t thought of it like that, but @JasonElkin makes a couple of fine points.. why post at all.. do it in js

To add more context, these are complex server-processing heavy forms with multiple fields, some are even grid-based forms. I’m not trying to rebuild these, I’m trying to do as little work as possible to eliminate the browser re-post warnings when going forward / back. Right now I’m thinking I might be able to make an ajax wrapper in js that posts the data and renders the html result via js (#4).

My question in large part is to ask why in Umbraco 8 surface controllers would return a result and not show a browser repost warning when navigating back and forward, but Umbraco 13 surface controllers do? I’m guessing it is because of how Umbraco 13 renders results to the browser (.Net Core maybe?)

In this post, Shannon seems to state that the older Umbraco 6 actually calls RedirectToCurrentUmbracoPage() after a surface controller submit. Not sure if this changed, if so that would explain why an older Umbraco 8 site shown no repost warnings, and Umbraco 13 does.