Login page Looping issue by using the OKTA ASP.net Middleware

We are having one strange issue where we redirect to the login page indefinitely after a successful login.
We get the 402 status code when we check but all the time we get redirected to the Login page and when we see the logs on the OKTa side, it says it is authenticating successfully.
We found a solution and reoslved this issue by putting a method in Global.asax
void Session_Start(object sender, EventArgs e)
{
// place holder to solve endless loop issue
}

After putting this above method into the Global.asax of the project, it resolved the issue.

Can someone please explain why this resolved the issue? We are kind of curious and want to find out the logical reason behind this solution to make sure that this does not happen in the future.