0

We are developing a shopping website where we make use of an external payment processor. When a user choose to pay then the amount and all other required arguments are sent to the 3rd party payment processor. Along with that, we also send a post ipn custom url. This is the url where the payment processor sends back the acknowkedgement.

I want to kickoff a bunch of time consuming operations in the background(asyncronous) when the control is sent back to this url. That way the user who is sitting on the UI of the payment processor does not sit there forever but instead gets the response back instantly. So for the background method to run I have made it async.

The problem is when I run the project the moment the control reaches to call the async method it gives me an exception of

An asynchronous operation cannot be started at this time. Asynchronous operations may only be started within an asynchronous handler or module or during certain events in the Page lifecycle. If this exception occurred while executing a Page, ensure that the Page is marked <%@ Page Async="true" %>.

How do I fix this? Remember the UI is not in my control. It is the UI of the payment processor. Any help please???

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
rsj
  • 61
  • 1
  • 2
  • 8
  • 1
    Did you do what the error message suggests? See also http://stackoverflow.com/q/14115620 – Robert Harvey Feb 04 '14 at 03:16
  • The error is coming out of the page which is not in my control. It is the page of the external processor where the exception is thrown... – rsj Feb 05 '14 at 02:43

1 Answers1

0

Given your constraints, the best way to achieve what you want is probably to stand up a Windows Service, or some similar independent processing mechanism, and use WCF to pass it your desired processing jobs.

You shouldn't keep this sort of thing on the ASP.NET Server, for all of the reasons that you've already mentioned, and a few others that you haven't mentioned yet.

Further Reading
Long-running ASP.NET tasks

Community
  • 1
  • 1
Robert Harvey
  • 178,213
  • 47
  • 333
  • 501