Reputation: 185
Under Stripe best practices for webhooks it states:
If your webhook script performs complex logic, or makes network calls, it’s possible that the script would time out before Stripe sees its complete execution. Ideally, your webhook handler code (acknowledging receipt of an event by returning a 2xx status code) is separate of any other logic you do for that event.
In C# how do I return a 200 response immediately and then carry out some other processing?
Upvotes: 1
Views: 369
Reputation: 1327
You can consider to use Task object. In BackendProcessing() write any custom logic you need. HttpStatusCode.OK will return 200.
public IHttpActionResult YouApiMethod()
{
var customLogic = new[]
{
Task.Run(() => BackendProcessing())
};
return new HttpStatusCodeResult(HttpStatusCode.OK);
}
Upvotes: 1