I have a ASP.NET Web API copy data from a third party application, and I am figuring out different options to reduce the response time of my API methods. API receives data and inserts into a table and then returns an HTTP Ok response. I would want to have the data copied and send a response back to the third party application and then do the processing of writing to the table.
public IHttpActionResult Post()
{
var ds = ReadFully(Request.Content.ReadAsStreamAsync().Result);
var dl = Encoding.UTF8.GetString(ds).Split(new string[] { Environment.NewLine, @"\r" }, StringSplitOptions.None).ToList();
write(dl);
if (errors.Count == 0)
return Ok("Success..");
else
return BadRequest("Error..");
}
public static byte[] ReadFully(Stream stream)
{
using (MemoryStream ms = new MemoryStream())
{
stream.CopyTo(ms);
return ms.ToArray();
}
}