1

I have integrated Payment Gateway in my Web Application made in MVC4 Razor. After payment has been done successfully the user is redirected to the return URL..

Then i do some process like generating unique id ,sending payment details sms blah blah..

[NoCache]
public ActionResult IPGResponse()
        {
            //Send SMS..
            //Save Payment Response..etc

            return RedirectToAction("ThankyouUploadDocument");
        }

Then I redirect to another Action.

public ActionResult ThankyouUploadDocument()
        {
            //Do Something

            return View("ThankyouUploadDocument" , paymentViewModel);
        }

The problem is when user hit back .It goes to IPGResponse() and do all steps again .

I have also used [NoCache]..but it did not worked

I have to Restrict the user to go back to the IPGResponse() or Payment Gateway again..

tereško
  • 58,060
  • 25
  • 98
  • 150
sunnykumar
  • 37
  • 1
  • 10
  • I think you can't. Store something in database, to know that this order is already processed – kpull1 Jul 31 '13 at 11:20
  • But i have seen some websites in which ...once you land to their Homepages..you can not go back to previous page...If user hits back button even though you are redirected to same page – sunnykumar Aug 01 '13 at 05:38
  • Maybe there's a redirection from one page to the following, but you can always go back twice directly. Or is opened in a new tab, so you lose your history. Or the processed url is stored in session, so it doesn't matter the url you type. – kpull1 Aug 06 '13 at 10:49

1 Answers1

0

This should prevent caching:

        HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
        HttpContext.Response.Cache.SetValidUntilExpires(false);
        HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
        HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        HttpContext.Response.Cache.SetNoStore();

and probably a good idea also server-check when form gets submitted and return error in case by some dark magic cache works. which it really shouldn't.

edit: this will prevent the browser's 'back' button from loading up cached page, which is what the question was about. Of course you would need check on page-enter to see if the transaction has already taken place.

mtbnunu
  • 302
  • 3
  • 11