0

We're trying to achieve the following story in MVC:

  1. Customer hits a regular action/view page and fills out a form. They click the submit button to post the values back to the controller, which in turn starts a long-running background process.

  2. Customer is redirected to a temporary 'processing - please wait' page. The page uses AJAX to periodically poll for a status update.

  3. When processing has completed, redirect customer to the result page.

KEY REQUIREMENT: If the customer hits the Back button in the browser at step 3, they should return to step 1. We DO NOT want the customer to go to step 2 and we don't want step 2 to appear in the browser history.

How can we achieve the above without the dreaded "Resubmit Posted Values?" message too?

Please note that I'm not looking for a discussion on the pros/cons of polling here. I know it's not the best solution in the world and we may well refactor using Signal R. The story is the important thing for me.

rae1
  • 6,066
  • 4
  • 27
  • 48
SimonGoldstone
  • 5,096
  • 3
  • 27
  • 38

2 Answers2

2

Simply apply the AJAX mechanism to step 1 (the page with the form) and use AJAX to POST the information back to the server and periodically poll the progress of the operation. You could dynamically hide/show the "Temporary Processing Page" using JavaScript without actually reloading the page.

rae1
  • 6,066
  • 4
  • 27
  • 48
  • Thanks. That's the option we are probably going to go with, other than the fact that we will need to handle form validation slightly differently. – SimonGoldstone Jun 10 '13 at 09:04
1

Perhaps when going to the resullt page, you could use window.location.replace (url); ?

Basically it will replace the current history item therefore they can't get back to it.

See this discussion for more info: window.location.replace (url);

Community
  • 1
  • 1
Rosdi Kasim
  • 24,267
  • 23
  • 130
  • 154
  • Thanks for your answer, which I found very helpful. Feels a bit 'dirty' though, fiddling with the browser history like that. Shame I can't achieve it naturally with HTTP/HTML. – SimonGoldstone Jun 10 '13 at 09:06