Reputation: 6060
While I am fully aware that disabling the back button is not a desirable trait of a website it may be the easiest solution for me at the moment. I had a deadline moved up on me at work and if it's easier would like to know if there is an easy way to disable the caching of the history during an application process. I fully intend to build in the ability to go back, but I just don't have time at the moment and would like to avoid some issues that may arise.
So while I'm fully aware that the back button is yours... but how can I make your back button go back to before you started the application and therefor need to restart (or whatever is the best situation in this bad situation).
I hope this makes sense and I've read the other post from when code behind pages were used, but didn't see any related to C# and MVC3. So please don't flame me for the need for this... it's a temporary band aid!
My ideal solution for this would be that when they hit the back button they are returned to the page before they started the application. This would hopefully maintain their previous history, but keep the application from breaking until I can build in the measures to catch and handle this.
Upvotes: 1
Views: 1244
Reputation: 101604
The ultimate end-all to browser history would be to use AJAX. This allows you to send/receive to/from the server without the client having a "go back" options. You can implement that with the method that Microsoft took for one of its demo MVC applications and allow each view to receive in an "ajax" parameter. When found, it returns the PartialView
of the page (less headers again) which you can then use to populate a common content element (say the <body> or
` element on the page).
However, this is arguably more work to implement then solving the original problem. I would probably track which stage they are in (I mentioned sessions, however you mentioned using a database) then either allow or forward them back on the "correct" path based on that value. This gives you a bit more flexibility, would be easier to implement (in time) and would keep all the verification on the server level. The only real issue you may have is that some browsers cache the results, so you may not get a re-fetch on the server, even though they've gone back in the process. If that's the case, you can make only this wizard-style portion of your page AJAX and leave the rest of the web site un-touched, which would effectively force them down the correct path.
Upvotes: 1