ASP.Net Webforms application logging out after visiting Payment Gateway

I am adding some features to an existing webforms application written in c# using .net framework 4.6. After redirecting to an external payment gateway, the site returns but the user ends up being logged out so the transaction does not complete.

The application uses a payment gateway to make credit card payments. Once the process starts, the applications redirects to payment gateway's site for a few seconds then returns to our checkout page. However the user is logged when the page returns. As a result the process does not complete

The session cookie is set to same site lax and secure.

I am using visual studio 2017 and working on my dev machine.The only thing I can think of so far is that session information is cleared whenever my application redirects to the payment gateway. So when it returns the user is no longer logged in. However, I do not know what to do to keep the session logged in.

Any assistance would be appreciated

1 answer

  • answered 2021-01-18 23:34 abujafar

    Seeing that I was working in Visual Studio 2017, when I ran the application, I was running with a URL of localhost:port_number e.g.'https://localhost:44390'. However, the url of the live site is something like 'https://www.specific.url.com'.

    The actual url was stored in the database and was being retrieved whenever the payment process was executed. This actual url was also being sent to the payment gateway as the return url. Upon return the live url: 'https://www.specific.url.com' did not match the dev url: https://localhost:44390. This somehow caused the session info to be lost.

    Once I changed the url in the database to https://localhost:44390, everything started working as expected.