Search code examples
c#asp.netopayo

Issue with site losing POST values with unexpected 302


I have been trying to work out an issue with Sagepay server intergration into a c#.net site. At first I believed that the Sagepay simulator was not sending back the POST.

I have since discovered that (during logging) that the simulator is POSTing the values back to the site but it is then losing them. I thought this might be an issue in global.asax.

I have tried commenting out everything in global.asax and the values from the simulator are still being lost.

I have been using log4net to track the stages this is one of the calls from the simulator and how my log4net puts it in the database:

Application_BeginRequest
Application_BeginRequest Request.UrlReferrer :
Application_BeginRequest Request.ServerVariables.Count : 49
Application_BeginRequest: Form count = 16
Application_AuthenticateRequest
Application_EndRequest
Application_PreSendRequestHeaders
Application_PreSendRequestContent
Application_End
Appliction Started
Application_BeginRequest
Application_BeginRequest Request.UrlReferrer :
Application_BeginRequest Request.ServerVariables.Count : 48
Application_BeginRequest: Form count = 0
Application_Begin Request.Form:
Application_AuthenticateRequest
Application_AuthorizeRequest
Application_ResolveRequestCache

That all happens within a few seconds. When it comes to load the page it has lost the post data.

This is the return we get on the sagepay simulator:

Raw Reponse from your Notification URL
Your Notification URL returned the following information in the response part of the POST. It has been formatted to wrap every 100 characters to make it more readable.

    <form method="post" action="/(A(ubPhPgmAzQEkAAAANzA1MTdhOTctZTJiZi00NzU3LWEyZjItODcxMzI2NW<BR>I3ZjA20))/PaymentGateway/SagePayServerReturn2.aspx" id="ctl00"><input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJMzIwOTI4NzM3ZGR7QWh08mOnnMUf7wtZMkwEWKknSW6n2TMurN5RJnAIbw==" />

We resorted back to using .asp to check that the simulator returned the POST and it works with .asp. We are really stuck as to why it shouldn't work in .aspx. Any help would be greatly appreciated.

Andrew

I have managed to update and get a least a valied respones now from sage page.

Status=INVALID
StatusDetail=Unable to find the transaction in our database.
RedirectURL=/PaymentGateway/SagePayOrderFailed.aspx?reasonCode=001

but it is still losing the post data some where as it firing the Application_BeginRequest twice.(I dont know if this is any help)

Found out why Application_BeginRequest is firing twice. When sage pay is sending the data to the page it is getting redirected to the same page.

So it is losing the data there however i have removed all of our redirect rules and it is still doing it. there are no Response.Redriect() in our solution. So i am lost where to look next for where the issues is occoring.


Solution

  • We have found the issue it was to do with anonymousIdentification in the web config.

    Within that the cookieless value was set and this was making it 302 to the same page which strip the post values. Didnt see that it was redireting till we checked the server logs.

    This is the code :
    <anonymousIdentification enabled="true" cookieName=".ASPXANONYMOUS" cookieTimeout="100000" cookieless="UseDeviceProfile" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="None" />

    So all we did is take out the cookieless value and the Sagepay now works a dream.