Search code examples
asp.net-mvcopayo

SagePay IFrame loads the Response URL in IFrame


We implemented SagePay in our .NET MVC project with IFrame method. However we are facing an issue with the response redirection.

After the successful payment via sage pay all the responses are loading within the IFrame itself. Where as we would like to redirect the response in the parent window itself.

We also noted that in the demo .NET Sage Kit, the redirection is happening correctly with the following code.

Response.Write(string.Format("RedirectURL={0}server/Result.aspx?Status={1}&VendorTxCode={2}", SagePaySettings.SiteFqdn, serverNotificationRequest.Status, serverNotificationRequest.VendorTxCode));

In our MVC frame work, we are also forming the url in the same format with a slightly different code, that is,

context.HttpContext.Response.Output.WriteLine("RedirectURL={0}PaymentResponse/Success?Status=OK&VendorTxCode={1}", SagePaySettings.SiteFqdn, response.VendorTxCode);

Could you please help us to solve this issue.


Solution

  • To make it happen I used, ContentResult for the action to update the parent URL.

    return new ContentResult
                {
    
                    Content = string.Format("<script type='text/javascript'>window.parent.location.href = '{0}';</script>", newurl),
                    ContentType = "text/html"
                };