---
title: "Asynchronous callback from web api controller"  
description: "Asynchronous callback from web api controller"  
author: "Anonymous User"  
published: 2013-12-17  
updated: 2013-12-17  
canonical: https://www.mindstick.com/forum/1788/asynchronous-callback-from-web-api-controller  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Asynchronous callback from web api controller

I'm very new to [Web API](https://www.mindstick.com/articles/324352/how-to-create-web-api-in-dot-net-core-3-1-mvc) and I have an unusual [pattern](https://www.mindstick.com/forum/2314/what-is-the-mvp-and-mvc-pattern) that I need to implement. In the [Post method](https://www.mindstick.com/forum/34628/server-get-post-method-in-php) of my [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc), it is to take an object which includes a CallbackURL. It will then immediately return an [HTTP response](https://www.mindstick.com/articles/1406/debugging-http-requests-and-http-response) to the caller. Afterwards, it will use a 3rd party, off-site API to perform some work with the object. Once that work is done, the controller is to post the [results](https://yourviews.mindstick.com/story/4497/usage-of-baking-soda-magical-results) of that work to the CallbackURL.

However, I do not know how to implement this in Web API. Once I return the HTTP response, the controller's [lifecycle](https://yourviews.mindstick.com/view/10392/how-is-the-vendor-lifecycle-impacting-the-energy-sector-in-north-america) is over, correct? If so, how do I perform the work I need to do after I [return the response](https://www.mindstick.com/forum/159729/how-can-i-return-the-response-from-an-asynchronous-call)?

## Replies

### Reply by Pravesh Singh

Hi John,

If you only need to post results to a url and not to the client that initiated the call, you could possibly do something as easy as this:

```
public string MyAPIMethod(object input){    Task.Factory.StartNew(() =>    {               //call third-party service and post result to callback url here.           });    return "Success!";}
```

The api call will return right away, and the Task you created will continue the processing in a different thread.


---

Original Source: https://www.mindstick.com/forum/1788/asynchronous-callback-from-web-api-controller

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
