I created a WebAPI method that will insert data into a database from the contents posted to the method.
My question is how can I push processing off so that the requester isn't hanging around for a response?
For example:
[HttpPost]
[Route("MyTest/ImportData")]
public HttpResponseMessage AddData([FromBody] XElement xmlBody)
{
try
{
// Verify that I can read the XML..
// Push XML off to another process to insert into database.
UpdateDataBase(xmlBody);
// Notify requester that I accepted the file.
return Request.CreateResponse(HttpStatusCode.OK);
}
catch (Exception ex)
{
return Request.CreateResponse(HttpStatusCode.InternalServerError);
}
}
What I have works. However it may take up to 4 minutes to insert all of the data. I would like to verify that I can read the xml, push the process off somehow and give the user an OK response.