Response.Redirect not firing due to code to prevent re-submission

Posted by Marco on Stack Overflow See other posts from Stack Overflow or by Marco
Published on 2010-04-21T16:54:16Z Indexed on 2010/04/23 8:23 UTC
Read the original article Hit count: 305

I have an event which needs to contact some third party providers before performing a redirect (think 'final payment page on ecommerce site') and hence has some lag associated with its processing. It is very important that these third party providers are not contacted more than once, and sometimes impatient users may try and refresh the page (hence re-submitting the data). The general code structure is:

If Session("orderStatus") <> 'processing' Then

    Session("orderStatus") = 'processing'

    DoThirdPartyStuffThatTakesSomeTime()

    Response.Redirect("confirmationPage.asp", True)

End If

The problem is, if the user refreshes the page, the response.redirect does not happen (even though the rest of the code will run before the redirect from the original submission). It seems that the new submission creates a new thread for the browser which takes precedence - it skips this bit of code obviously to prevent the third party providers being contacted a second time, and since there is no redirect, just comes back to the same page. The whole second submission may have completed before the first submission has finished its job.

Any help on how I can still ignore all of the subsequent submissions of the page, but still make the redirect work...?

Thanks

© Stack Overflow or respective owner

Related posts about response.redirect

Related posts about threading