'Confirm form resubmission - ASP.NET 5 MVC

I have two controllers Booking and Checkout. Posting form data from controller Booking to Checkout index get page.

I want to retrieve the object submitted when clicking the back button from Checkout to Booking index get page.

(same error applies even if I refresh the page meanwhile I am in checkout page)

Confirm Form Resubmission
This webpage requires data that you entered earlier in order to be properly displayed. 
You can send this data again, but by doing so you will repeat any action this page previously performed.
Press the reload button to resubmit the data needed to load the page.

ERR_CACHE_MISS

BookingController

public async Task<IActionResult> Index(CarsBookingVM carsBooking)
{
    return View(carsBooking);
}

BookingIndex.cshtml

<form asp-controller="Checkout" asp-action="Index">
<input hidden value="@Model.CarId" name="carId">
<input type="submit" value="Proceed">
</form>

CheckoutController

[HttpGet]
public async Task<IActionResult> Index(int? carId)
{
    BookingVM booking = new BookingVM(){
    //...

    return View(booking);
}

[HttpPost]
public async Task<IActionResult> Create(BookingVM booking)
{
    //...
}


Solution 1:[1]

Because of the sloppy coding practices of web developers browsers were forced to add this message. the scenario is as follows:

  1. user fills in form and submits (posts form)
  2. the server process the post data and responds with a new page (confirm) marked as not cacheable
  3. the user navigates to a new page.
  4. the user press back:

For the the browser to display the page in step 2, because its marked no-cache, it must request it from the server, in other words do the repost of the data (do step 1). here is were the sloppy coding came in, if this was an credit card charge, and repost detection was not on the server, the card is charged twice. this was (is) so common a problem, that the browsers had to detect this and warn the users.

the best fix is in step two, the server sends a redirect to the confirm page. then when the user accesses the confirm via history or back, its a get request, not a post request and will not show the warning.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1