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..

4

1 回答 1

0

这应该防止缓存:

        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();

当表单被提交并返回错误以防某些暗魔法缓存工作时,服务器检查可能也是一个好主意。它真的不应该。

编辑: 这将阻止浏览器的“后退”按钮加载缓存页面,这就是问题所在。当然,您需要检查页面输入以查看交易是否已经发生。

于 2013-08-02T19:56:18.373 回答